File tree Expand file tree Collapse file tree 8 files changed +196
-0
lines changed
Lecture Example BAO 2019/src/com/rt Expand file tree Collapse file tree 8 files changed +196
-0
lines changed Original file line number Diff line number Diff line change
1
+
2
+ package com .rt .covariant ;
3
+
4
+ public class A {
5
+
6
+ int a ,b ;
7
+
8
+ public A myfun (int a ,int b ){
9
+ System .out .println ("Original method" +a +" " +b );
10
+ return new A ();
11
+
12
+ }
13
+
14
+
15
+ }
Original file line number Diff line number Diff line change
1
+
2
+ package com .rt .covariant ;
3
+
4
+ public class ABCmain {
5
+
6
+ /**
7
+ * @param args
8
+ */
9
+ public static void main (String [] args ) {
10
+ // TODO Auto-generated method stub
11
+ A ob1 =new A ();
12
+ B ob2 =new B ();
13
+ C ob3 =new C ();
14
+
15
+ System .out .println ( ob1 .myfun (2 , 3 ));
16
+ System .out .println (ob2 .myfun (2 , 3 ));
17
+ System .out .println (ob3 .myfun (2 , 3 ));
18
+
19
+ }
20
+
21
+ }
Original file line number Diff line number Diff line change
1
+
2
+
3
+ package com .rt .covariant ;
4
+
5
+ public class B extends A {
6
+
7
+ @ Override
8
+ public C myfun (int a , int b ) {
9
+ // TODO Auto-generated method stub
10
+ System .out .println ("my implementation B" +a +" " +b );
11
+ return new C ();
12
+
13
+ }
14
+
15
+ }
Original file line number Diff line number Diff line change
1
+
2
+
3
+ package com .rt .covariant ;
4
+
5
+ public class C extends B {
6
+
7
+
8
+
9
+ @ Override
10
+ public C myfun (int a , int b ) {
11
+ // TODO Auto-generated method stub
12
+ System .out .println ("my implementation C" +a +" " +b );
13
+ return new C ();
14
+ }
15
+
16
+ }
Original file line number Diff line number Diff line change
1
+ package com .rt .inheritence ;
2
+
3
+ public class A {
4
+
5
+ public A () {
6
+ // TODO Auto-generated constructor stub
7
+ System .out .println ("Object of A created thru Constructor of A" );
8
+ }
9
+
10
+ int a =10 ;
11
+
12
+ public void fun3 ()
13
+ {
14
+ System .out .println ("I am fun3 from A" );
15
+
16
+ }
17
+
18
+ public static void fun1 ()
19
+ {
20
+ System .out .println ("I am from static of A" );
21
+
22
+ }
23
+
24
+ // public abstract void fun2();
25
+
26
+ public static void TestStatic ()
27
+ {
28
+ System .out .println ("i am Teststatic of A" );
29
+ }
30
+
31
+ }
Original file line number Diff line number Diff line change
1
+ package com .rt .inheritence ;
2
+
3
+ public class B extends A {
4
+ int a =20 ;
5
+
6
+ public B () {
7
+ // TODO Auto-generated constructor stub
8
+
9
+ System .out .println ("Object created thru Constructor of B" );
10
+
11
+ }
12
+
13
+ public static void fun1 ()
14
+ {
15
+ System .out .println ("I am from static of A" );
16
+
17
+ }
18
+
19
+ public void fun3 ()
20
+ {
21
+ System .out .println ("I am Fun 3 from B" );
22
+
23
+ }
24
+
25
+
26
+
27
+
28
+
29
+
30
+ }
Original file line number Diff line number Diff line change
1
+ package com .rt .inheritence ;
2
+
3
+ public class SamplePrivate {
4
+
5
+ static int count =0 ;
6
+
7
+ private SamplePrivate () {
8
+ // TODO Auto-generated constructor stub
9
+ }
10
+
11
+ public static SamplePrivate fun1 ()
12
+ {if (count <3 )
13
+ { count ++;
14
+ System .out .println ("Hello" +count +"Object creted" );
15
+ return new SamplePrivate ();
16
+ }
17
+ else
18
+ {
19
+ System .out .println ("MAXIMIMUM LIMIT REACHED" );
20
+ return null ;
21
+
22
+ }
23
+ }
24
+
25
+ static SamplePrivate obj =new SamplePrivate ();
26
+
27
+
28
+ }
Original file line number Diff line number Diff line change
1
+ package com .rt .inheritence ;
2
+
3
+ public class TestClass {
4
+
5
+ /**
6
+ * @param args
7
+ */
8
+ public static void main (String [] args ) {
9
+ // TODO Auto-generated method stub
10
+
11
+ // A obj=new A();
12
+ // B obj2=new B();
13
+ A .fun1 ();
14
+
15
+ // SamplePrivate.obj.f1();
16
+ // SamplePrivate obj2=new SamplePrivate();
17
+
18
+
19
+ // SamplePrivate obj1=SamplePrivate.fun1();
20
+ // SamplePrivate obj2=SamplePrivate.fun1();
21
+ // SamplePrivate obj3=SamplePrivate.fun1();
22
+ // SamplePrivate obj4=SamplePrivate.fun1();
23
+ ////
24
+ ////
25
+ // obj.fun2();
26
+ // obj2.fun2();
27
+ // A.fun1();
28
+ // B.fun1();
29
+ // A.TestStatic();
30
+ // B.TestStatic();
31
+ ////
32
+
33
+ // SamplePrivate.obj.fun1();
34
+ // SamplePrivate obj2=
35
+
36
+
37
+
38
+ }
39
+
40
+ }
You can’t perform that action at this time.
0 commit comments