-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExample.java
More file actions
24 lines (18 loc) · 741 Bytes
/
Example.java
File metadata and controls
24 lines (18 loc) · 741 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
package oops;
public class Example {
public static void main(String[] args) {
// TODO Auto-generated method stub
Javamodifierprivate myobj=new Javamodifierprivate();
//System.out.println(myobj.age);
//shows error because age is only accessible in Javamodifierprivate class only
//it can't be accessible on different class
Javamodifierprotected my= new Javamodifierprotected();
System.out.println(my.fname); //protected can be accessed in same package,subclass,super class
//program for Javaencapsulation.java
Javaencapsulation obj = new Javaencapsulation();
obj.setname("Sunil Shetty");
System.out.println(obj.getname());
obj.setNum(40);
System.out.println(obj.getNum());
}
}