forked from 3point141/java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathencap.java
More file actions
40 lines (34 loc) · 775 Bytes
/
encap.java
File metadata and controls
40 lines (34 loc) · 775 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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import java.io.*;
import java.util.*;
class student
{
int age;
String name;
public student()
{
age=0;
name="aaa";
}
public student(int a ,String b)
{
age=a;
name=b;
}
}
class encap
{
public static void main(String[] args) throws IOException
{
BufferedReader x = new BufferedReader(new InputStreamReader(System.in));
System.out.println("enter age : ");
int age=Integer.parseInt(x.readLine());
System.out.println("\n enter name : ");
String name=x.readLine();
System.out.println("default constructer : ");
student s=new student();
System.out.println("age : "+s.age+" name : "+s.name);
student s1=new student(age,name);
System.out.println("parameterised constructer : ");
System.out.println("age : "+s1.age+" name : "+s1.name);
}
}