-
Notifications
You must be signed in to change notification settings - Fork 0
/
encap.java
42 lines (35 loc) · 935 Bytes
/
encap.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/******************************************************************************
Online Java Compiler.
Code, Compile, Run and Debug java program online.
Write your code in this editor and press "Run" button to execute it.
*******************************************************************************/
public class encap
{
public static void main(String[] args) {
System.out.println("Hello World");
Laptop l1= new Laptop();
l1.setp(56);
}
}
class Laptop {
int ram;
private int price;
public void setp(int price){
/// if it is admin
boolean isadmin = false;
if(!isadmin){
System.out.println(" you cant change");
}
{
this.price = price;
}
}
/// getter
public int ram(){
return ram;
}
//setter
public void ram(int ram){
this.ram = ram;
}
}