Challenge: Declaring Class Attributes

Follow along with the statements mentioned in the problem to solve the challenge related to class attributes.

We'll cover the following

Problem statement

Declare the following in the given FatherPanda class:

  • Declare a public boolean type variable and name it isPredator.

  • Declare a protected int type variable and name it weight.

  • Declare a private int type variable and name it age.

  • Declare a public void function, name it eat and print the following statements (each statement on a new line):

    • After each meal, Father Panda gains weight: (print weight in front of it)

    • And his age is: (print age in front of it)

Uncomment the three lines after declaring the class attributes in the main function to pass the challenge:

Get hands-on with 1400+ tech skills courses.