4. Classes-Instance Variables


#1

How do you solve this question?

Let's model the Dog class after a real-world dog. Create an int instance variable called age.

class Dog {

public static void main(String[] args) {

}

}


#2

class Dog {
int age;
public Dog() { }
public static void main(String[] args) {

}

}


#3

//Hello @nikesh19hotmail_co_u
//I worked it out like shown below and it worked.

class Dog {
//Create an int instance variable called age
int age;

public Dog() {
}

public static void main(String [] args){

}

}