Type Here to Get Search Results !

10. Write a JAVA program to give the example for ‘this’ operator. And also use the ‘this’ keyword as return statement.

 class Square 

 int height; 

 int width; 

Square(int height, int width) 

 { 

 this.height = height; 

 this.width = width; 

 } 

}

class ImplSquare 

 public static void main(String args[]) 

 { 

 Square sObj = new Square(4,6); 

 System.out.println("Variable values of object : ");  System.out.println("Object height = " + sObj.height);  System.out.println("Object width = " + sObj.width);  } 

Post a Comment

0 Comments
* Please Don't Spam Here. All the Comments are Reviewed by Admin.

Featured post

M

M