0% found this document useful (0 votes)
10 views2 pages

ActivityModularkey Answer

The document outlines a Computer Programming 1 assignment for students at Benigno V. Aldana National High School, focusing on Java programming. It includes tasks to create an abstract class 'Animal' with subclasses 'Lion', 'Tiger', and 'Deer', as well as a method to handle exceptions for odd integers. The document also includes sections for signatures from teachers and guardians.

Uploaded by

orcvoid
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views2 pages

ActivityModularkey Answer

The document outlines a Computer Programming 1 assignment for students at Benigno V. Aldana National High School, focusing on Java programming. It includes tasks to create an abstract class 'Animal' with subclasses 'Lion', 'Tiger', and 'Deer', as well as a method to handle exceptions for odd integers. The document also includes sections for signatures from teachers and guardians.

Uploaded by

orcvoid
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Republic of the Philippines

Department of Education
Region I
PANGASINAN SCHOOLS DIVISION OFFICE II
BENIGNO V. ALDANA NATIONAL HIGH SCHOOL
CABLONG, POZORRUBIO, PANGASINAN
Computer Programming 1

NAME: ________________________________________
Scores:
STRAND: ______________________________________ Date: ________

1. Write a Java program to create an abstract class Animal with abstract methods eat() and
sleep(). Create subclasses Lion, Tiger, and Deer that extend the Animal class and implement
the eat() and sleep() methods differently based on their specific behavior.
- this program, the Animal class is an abstract class that defines the abstract methods eat()
and sleep(). The Lion, Tiger, and Deer classes extend the Animal class and provide their
own implementations for the eat() and sleep() methods based on their specific behavior.
The Main class demonstrates the usage of these classes by creating objects of each subclass
and invoking the eat() and sleep() methods accordingly.

Output:

Lion eats meat.


Lion sleeps on grassland.

Tiger eats meat and occasionally hunts in water.


Tiger sleeps in a hidden spot.

Deer grazes on grass and leaves.


Deer sleeps in open fields.

2. Write a Java program to create a method that takes an integer as a parameter and throws an
exception if the number is odd.

Output:
18 is even.
Error: 7 is odd.

3.

Prepared by: Approved by: Noted by:

RAQUEL S. QUINIT ROGER Z. ESTABILLO JR. PhD EDDIE M. RAGUINDIN EdD


Teacher II Assistant School Principal IV EPS – Science / OIC Principal IV

_________________________________________________________
SIGNATURE OVER PRINTED NAME OF PARENTS/GAURDIAN
4.

You might also like