Skip to content

Commit c8e648a

Browse files
main
1 parent f0576ec commit c8e648a

File tree

7 files changed

+179
-1
lines changed

7 files changed

+179
-1
lines changed

.vscode/settings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
"12.Inheritance",
1818
"13.Polymorphism",
1919
"14.Abstraction&Interface",
20-
"15.InnerClass"
20+
"15.InnerClass",
21+
"16.ExceptionHandling"
2122
],
2223
"java.debug.settings.onBuildFailureProceed": false
2324
}

15.InnerClass/AnnonymousIC/Normal/2_annonymous.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ Demo2 fun(){
3434
obj.marry();
3535

3636
System.out.println(obj.x);
37+
38+
// if we try to create new class object then whole class is created
3739

3840

3941
}

15.InnerClass/MethodLocalIC/1_Method.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,20 @@ class Current
88
class saving
99
1010
take loan
11+
12+
13+
2.class Phone pay:
14+
method:
15+
transaction:
16+
class Bank names:
17+
18+
19+
3.class Play Store:
20+
method:
21+
Update:
22+
class Apps:
23+
24+
3.
1125
1226
*/
1327

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
package MethodLocalIC;
2+
3+
class Outer2{
4+
5+
void fun(){
6+
System.out.println("In Outer fun");
7+
8+
class Inner2{
9+
10+
private int x =10;
11+
static int y =20;
12+
13+
static{
14+
int p =56;
15+
System.out.println(p);
16+
}
17+
18+
{
19+
System.out.println("In instance 1");
20+
}
21+
void fun(){
22+
System.out.println("Inner fun");
23+
}
24+
25+
static{
26+
int z =90;
27+
System.out.println(z);
28+
}
29+
30+
Inner2(){
31+
System.out.println("In constructor");
32+
}
33+
34+
{
35+
System.out.println("In Instance 2");
36+
}
37+
}
38+
39+
Inner2 obj = new Inner2();
40+
obj.fun();
41+
System.out.println(obj.x);
42+
System.out.println(obj.y);
43+
44+
}
45+
46+
47+
void gun(){
48+
49+
System.out.println("In Outer Gun");
50+
}
51+
}
52+
53+
class Client2{
54+
55+
public static void main(String[] args) {
56+
57+
Outer2 obj = new Outer2();
58+
obj.fun();
59+
obj.gun();
60+
61+
}
62+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
package MethodLocalIC;
2+
3+
class Outer3{
4+
5+
Object fun(){
6+
System.out.println("In Outer fun");
7+
8+
class Inner3{
9+
10+
void fun(){
11+
System.out.println("Inner fun");
12+
}
13+
14+
}
15+
16+
return new Inner3();
17+
}
18+
19+
void gun(){
20+
System.out.println("Outer gun");
21+
}
22+
}
23+
24+
class Client3{
25+
26+
public static void main(String[] args) {
27+
28+
Outer3 obj = new Outer3();
29+
obj.fun().fun(); // object class parent of all other classes directly or indirectly
30+
}
31+
}
32+
33+
34+
/*
35+
36+
37+
Output:
38+
.\3_Method.java:29: error: cannot find symbol
39+
obj.fun().fun(); // object class parent of all other classes directly or indirectly
40+
^
41+
symbol: method fun()
42+
location: class Object
43+
1 error
44+
45+
46+
*/
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package StaticNestedIC;
2+
3+
import StaticNestedIC.Outer3.Inner3;
4+
5+
class Outer3{
6+
7+
void fun(){
8+
System.out.println("Outer fun");
9+
}
10+
11+
static class Inner3{
12+
13+
void fun(){
14+
System.out.println("Inner fun");
15+
}
16+
}
17+
}
18+
19+
class Client3{
20+
public static void main(String[] args) {
21+
22+
Outer3.Inner3 obj = new Inner3();
23+
Outer3.Inner3 obj1 = new Outer3.Inner3();
24+
}
25+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
2+
package CompileTime;
3+
4+
import java.io.BufferedReader;
5+
import java.io.IOException;
6+
import java.io.InputStreamReader;
7+
8+
class demo{
9+
10+
public static void main(String[] args)throws IOException {
11+
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
12+
13+
System.out.println("Enter the string: ");
14+
String name = br.readLine();
15+
System.out.println(name);
16+
17+
System.out.println("Enter the character: ");
18+
char ch = (char)br.read();
19+
System.out.println(ch);
20+
br.skip(2);
21+
22+
23+
System.out.println("Enter the character: ");
24+
char ch1 = br.readLine().charAt(0);
25+
System.out.println(ch1);
26+
}
27+
28+
}

0 commit comments

Comments
 (0)