What is encapsulation in java:
=========================
Encapsulation is the process of wrapping the data in to a single unit or container.
Every java class is an example of encapsulation.
=========================
Encapsulation is the process of wrapping the data in to a single unit or container.
Every java class is an example of encapsulation.
package blog;
class Test1
{
int a;
String str;
Test1(int a,String str)
{
this();//calling current class default constructor
this.a=a;
this.str=str;
}
Test1()
{
System.out.println("default constructor");
}
}
class Test2 extends Test1
{
int a,c;
String str;
Test2(int a,String str,int c)
{
super();//calling super class constructor
this.a=a;
this.str=str;
this.c=c;
}
}
public class ThisSuperDemo {
public static void main(String[] args) {
Test1 test1 = new Test1(80,"selenium");
Test2 test2 = new Test2(10,"Ramesh Selenium",90);
System.out.println(test2.a);
System.out.println(test2.c);
System.out.println(test2.str);
}
}
Nice Post. Keep posting, oracle rac online training
ReplyDeletemsbi online training