-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathLab8.java
More file actions
36 lines (29 loc) · 716 Bytes
/
Lab8.java
File metadata and controls
36 lines (29 loc) · 716 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
// 8: Develop a Java program to create a class Outer with a function display().
// Create another class Inner with a function display() and call two functions in the main class.
class Outer {
private int x = 10;
class Inner {
private int y = 20;
void display() {
System.out.println("X: " + x + " Y:" + y);
}
}
void display() {
Inner i = new Inner();
i.display();
System.out.println("Y: " + i.y);
}
}
public class Lab8 {
public static void main(String[] args) {
Outer o = new Outer();
Outer.Inner obj = o.new Inner();
o.display();
obj.display();
}
}
/*
* Output:
* X: 10 Y:20
* Y: 20
*/