Last Updated on by ICT Byte
Invoking Base Class Constructor
- To invoke base class constructor , super keyword is used
// Java program for demonstration of inheritence
class Mcs {
// Creating method method1 for class Mcs
public void method1()
{
System.out.println(“mcs”);
}
}
class Oop extends Mcs {
// Creating method method2 for class oop
public void method2()
{
System.out.println(“oop”);
}
}
public class IB {
public static void main(String[] args)
{
// Creating Obj for Class Oop and
// Calling both method1 from class mcs
// And calling method2 from class oop respectively.
Oop obj = new Oop();
obj.method2();
obj.method1();
}
}
Objects and Arrays