Professional Documents
Culture Documents
Lab 6
Lab 6
Task 1: Implement the setter/getter functions using following code (Slide 11, lecture 5)
CODE:
int a ;
public int b;
private int c;
c=i;
int getc(){
return c;
/**
*/
ob.a=10;
ob.b=20;
ob.setc(100);
Output:
Task2: Write a code that calls a static function in main (outside class) (reference Lecture 5)
CODE:
static int a = 42 ;
System.out.println("a= "+a);
/**
*/
StaticDemo.callme();
System.out.println("b= " + StaticDemo.b);
OUTPUT: