Define java class Kids with contructors


Define java class Kids that has two private instance variables name and age.

Define three overloaded constructor methods with zero argument (receives no name and no age),

one argument (receives only name) (0.5 mark ) and two arguments (receives name and age).. Additionally, define all sets and gets methods.


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.
  • Instantiate one object k2 of type Kids using one argument constructor and pass "Omar" as a parameter.
  • Instantiate one object k3 of type Kids using two argument constructor and pass "Anas" as the first parameter and 10 as second parameter.
  • Change the name of object k1 to "Hamza" and the age to 8.
  • Change the age of the object k2 to 5.
  • Print the names of all kid objects whose age are greater than 6 years old.

All Answers

total answers (0)

This question belongs to these collections

Similar questions

need a help?

find thousands of online teachers now