File tree 7 files changed +179
-1
lines changed
16.ExceptionHandling/CompileTime
7 files changed +179
-1
lines changed Original file line number Diff line number Diff line change 17
17
" 12.Inheritance" ,
18
18
" 13.Polymorphism" ,
19
19
" 14.Abstraction&Interface" ,
20
- " 15.InnerClass"
20
+ " 15.InnerClass" ,
21
+ " 16.ExceptionHandling"
21
22
],
22
23
"java.debug.settings.onBuildFailureProceed" : false
23
24
}
Original file line number Diff line number Diff line change @@ -34,6 +34,8 @@ Demo2 fun(){
34
34
obj .marry ();
35
35
36
36
System .out .println (obj .x );
37
+
38
+ // if we try to create new class object then whole class is created
37
39
38
40
39
41
}
Original file line number Diff line number Diff line change @@ -8,6 +8,20 @@ class Current
8
8
class saving
9
9
10
10
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.
11
25
12
26
*/
13
27
Original file line number Diff line number Diff line change
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
+ }
Original file line number Diff line number Diff line change
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
+ */
Original file line number Diff line number Diff line change
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
+ }
Original file line number Diff line number Diff line change
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
+ }
You can’t perform that action at this time.
0 commit comments