File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ public class StringManipulation {
44
55 public static void main (String [] args ) {
66
7- String s = "The rains have started here" ;
7+ String s = "The rains have started here selenium " ;
88
99 System .out .println (s .length ());
1010
@@ -55,7 +55,6 @@ public static void main(String[] args) {
5555 String firstName1 [] = firstName .split (";" );
5656 for (int i =0 ; i <firstName1 .length ; i ++){
5757 System .out .println (firstName1 [i ]);
58-
5958 }
6059
6160
Original file line number Diff line number Diff line change 1+ package OOPConcept ;
2+
3+ public class BMW extends Car {
4+
5+ //Method Overriding:
6+ //when the method name is same with the same number of arguments
7+ //in parent class as well as in child class
8+ public void start (){
9+ System .out .println ("BMW--start" );
10+ }
11+
12+
13+ public void theftSafety (){
14+ System .out .println ("BMW--thefetSafety" );
15+ }
16+
17+
18+
19+
20+
21+
22+ }
Original file line number Diff line number Diff line change 1+ package OOPConcept ;
2+
3+ public class Car {
4+
5+ public void start (){
6+ System .out .println ("Car--start" );
7+ }
8+
9+ public void stop (){
10+ System .out .println ("Car--stop" );
11+ }
12+
13+ public void refuel (){
14+ System .out .println ("Car--refuel" );
15+ }
16+
17+
18+
19+
20+
21+ }
Original file line number Diff line number Diff line change 1+ package OOPConcept ;
2+
3+ public class TestCar {
4+
5+ public static void main (String [] args ) {
6+
7+ BMW b = new BMW ();
8+ b .start (); //compile time polymorphism
9+ b .stop ();
10+ b .refuel ();
11+ b .theftSafety ();
12+
13+ System .out .println ("*******" );
14+
15+ Car c = new Car ();
16+ c .start ();
17+ c .stop ();
18+ c .refuel ();
19+
20+ System .out .println ("*******" );
21+
22+ Car c1 = new BMW ();//child class object can be referred by parent class reference variable
23+ //dynamic/Run Time polymorphism
24+ //Top casting
25+ c1 .start ();
26+ c1 .stop ();
27+ c1 .refuel ();
28+
29+ BMW b1 = (BMW ) new Car (); //down casting: ClassCastException
30+
31+
32+ }
33+
34+ }
You can’t perform that action at this time.
0 commit comments