NEP -JAVA

PROGRAM 1 PROGRAM 2 PROGRAM 3 PROGRAM 4 PROGRAM 5 PROGRAM 6

PART B

PROGRAM B1 PROGRAM B2 PROGRAM B3 PROGRAM B4 PROGRAM B5 PROGRAM B6 PROGRAM B7 PROGRAM B8 . . .

3

 
 
  
  
  /*3.Program with class variable that is available for all instances of a class. Use
static variable declaration. Observe the changes that occur in the object’s
member variable values.
.*/

    public class CountObject  
    {  
    //variable to keep track of objects  
    private static int count;  
    //constructor of the class  
    public CountObject()   
    {  
    // increase the count variable by 1  
    count++;  
    }  
    public static void main(String args[])   
    {  
    //creating objects  
    CountObject ob1 = new CountObject();  
    CountObject ob2 = new CountObject();  
    CountObject ob3 = new CountObject();  
    CountObject ob4 = new CountObject();  
    CountObject ob5 = new CountObject();  
    //prints number of objects  
    System.out.print("Total Number of Objects: " + CountObject.count);  
    }  
    }