Page 473 - Computer science 868 Class 12
P. 473
10 { public void sqArea()
11 { int a=s*s;
12 System.out.println("Side ="+s+" Area of square="+a);
13 }
14 public void cirArea()
15 { double a=3.142*r*r;
16 System.out.println("Radius ="+r+" Area of circle="+a);
17 }
18 public static void main()
19 { Area ob=new Area();
20 ob.sqArea();
21 ob.cirArea();
22 }
23 }
The output of the preceding program is as follows:
Let’s Revisit
♦ Inheritance can be defined as an OOP paradigm in which the derived class acquires the characteristics of the base class.
♦ The extends keyword in Java indicates that the derived class inherits the properties of the base class.
♦ The super key word in Java is a reference variable which is used to refer to the variables and methods of the base class.
♦ When we have methods having the same name and signature, one belonging to the base class and other to the derived class,
then the method of the derived class is said to override the methods of the base class and is executed. This concept is called
method overriding.
♦ Visibility modes are used to implement the OOP concept of data hiding. It controls which members of the parent class can be
accessible in the child class.
♦ The different types of Inheritance are Single, Multilevel, Multiple, Hierarchical and Hybrid.
♦ Polymorphism in Java refers to the same object having multiple forms and attributes.
♦ Method Overloading is a programming technique which allows multiple methods of a class to have the same name, but
different signatures.
♦ If the method is matched with the right method definition by the compiler at compile-time, it is called static binding.
♦ If the method is matched with the right method definition by the compiler at run-time, it is called dynamic binding.
♦ The final keyword is a non-access modifier used for classes, attributes and methods, which makes their properties unalterable.
♦ The keyword abstract is a Java modifier which can be applied only to Java classes and methods only.
♦ Abstract methods are the methods with only method declaration but no method body.
♦ Interface in Java is a blue print of a class as it specifies what to do, but how to do is not specified.
471
Inheritance, Interfaces and Polymorphism 471

