Question: Q 3 . Writing program ( 7 marks ) Define java class Kids that has two private instance variables name and age ( 0 .

Q3. Writing program
(7 marks)
Define java class Kids that has two private instance variables name and age (0.5 mark). Define three overloaded constructor methods with zero argument (receives no name and no age)(0.5 mark ), one argument (receives only name)(0.5 mark ) and two arguments (receives name and age)(0.5 mark).. Additionally, define all sets and gets methods (1 mark).
Define a Java class TestKids that contains a main method and test the functionality of the above class Kids as the following:
Instantiate one object k1 of type Kids using zero argument constructor. (0.5 mark)
Instantiate one object k2 of type Kids using one argument constructor and pass "Omar" as a parameter. (0.5 mark)
Instantiate one object k3 of type Kids using two argument constructor and pass "Anas" as the first parameter and 10 as second parameter. (0.5 mark)
Change the name of object k1 to "Hamza" and the age to 8.(1 mark)
Change the age of the object k2 to 5.(0.5 mark)
Print the names of all kid objects whose age are greater than 6 years old. (1 mark)
 Q3. Writing program (7 marks) Define java class Kids that has

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!