Posted on

MCSL025 Java Lab Records 3

Session 7 : Multithreading  Ex 23: Write a program to launch 10 threads. Each thread increments a counter variable. Run the program with synchronization.  Code: class s07_02 { public static void main(String arg[])throws Exception { data d1=new data(); data d2=new data(); data d3=new data(); data d4=new data(); data d5=new data(); data d6=new data(); data d7=new data(); data d8=new…

Read more

Posted on

MCSL025 Java Lab Records 3

Session 7 : Multithreading  Ex 23: Write a program to launch 10 threads. Each thread increments a counter variable. Run the program with synchronization.  Code: class s07_02 { public static void main(String arg[])throws Exception { data d1=new data(); data d2=new data(); data d3=new data(); data d4=new data(); data d5=new data(); data d6=new data(); data d7=new data(); data d8=new…

Read more

Posted on

MCSL025 Java Lab Records 3

Session 7 : Multithreading  Ex 23: Write a program to launch 10 threads. Each thread increments a counter variable. Run the program with synchronization.  Code: class s07_02 { public static void main(String arg[])throws Exception { data d1=new data(); data d2=new data(); data d3=new data(); data d4=new data(); data d5=new data(); data d6=new data(); data d7=new data(); data d8=new…

Read more

Posted on

MCSL025 Java Lab Records 2

Session 4 : Inheritance and Polymorphism  Ex 10: Write a Java program to show that private member of a super class cannot be accessed from derived classes.  Code: class room { private int l,b; room(int x,int y) { l=x; b=y;} int area() {return(l*b);} } class class_room extends room { int h; class_room(int x,int y,int z) { super(x,y); h=z;…

Read more

Posted on

MCSL025 Java Lab Records 1

Session 1 : Data Types, Variables & Operators Ex 1: Write a program in Java to implement the formula (Area = Height ×Width) to find the area of a rectangle. Where Height and Width are the rectangle‟s height and width.  Code: class rectangle { int h,w; rectangle(int x,int y) { h=x; w=y; } int area() {…

Read more

Posted on

MCSL025 Java Lab Records 1

Session 1 : Data Types, Variables & Operators Ex 1: Write a program in Java to implement the formula (Area = Height ×Width) to find the area of a rectangle. Where Height and Width are the rectangle‟s height and width.  Code: class rectangle { int h,w; rectangle(int x,int y) { h=x; w=y; } int area() {…

Read more

Posted on

MCSL025 Java Lab Records 2

Session 4 : Inheritance and Polymorphism  Ex 10: Write a Java program to show that private member of a super class cannot be accessed from derived classes.  Code: class room { private int l,b; room(int x,int y) { l=x; b=y;} int area() {return(l*b);} } class class_room extends room { int h; class_room(int x,int y,int z) { super(x,y); h=z;…

Read more

Posted on

MCSL025 Java Lab Records 1

Session 1 : Data Types, Variables & Operators Ex 1: Write a program in Java to implement the formula (Area = Height ×Width) to find the area of a rectangle. Where Height and Width are the rectangle‟s height and width.  Code: class rectangle { int h,w; rectangle(int x,int y) { h=x; w=y; } int area() {…

Read more

Posted on

MCSL025 Java Lab Records 2

Session 4 : Inheritance and Polymorphism  Ex 10: Write a Java program to show that private member of a super class cannot be accessed from derived classes.  Code: class room { private int l,b; room(int x,int y) { l=x; b=y;} int area() {return(l*b);} } class class_room extends room { int h; class_room(int x,int y,int z) { super(x,y); h=z;…

Read more