This is a Java Program to Access Super Class in a Method Overriding.
Here we made get() method in both base and child class. Child class override the method of base class and to run both methods we use the Super keyword.
Here is the source code of the Java Program to Access Super Class in a Method Overriding. The Java program is successfully compiled and run on a Windows system. The program output is also shown below.
class Base
{
void get()
{
System.out.println(" Base class method via Super keyword");
}
}
class Child extends Base
{
void get()
{
super.get();
System.out.println("Child class method");
}
public static void main(String... a)
{
Child obj1 = new Child();
obj1.get();
}
}
Output:
$ javac Child.java $ java Child Base class method via Super keyword Child class method
Sanfoundry Global Education & Learning Series – 1000 Java Programs.
advertisement
advertisement
Here’s the list of Best Books in Java Programming, Data Structures and Algorithms.
If you find any mistake above, kindly email to [email protected]Related Posts:
- Practice Programming MCQs
- Apply for Computer Science Internship
- Practice BCA MCQs
- Check Programming Books
- Practice Information Technology MCQs