Skip to Main Content
Java Programming by Pearson
book

Java Programming by Pearson

by Hari Mohan Pandey
May 2024
Intermediate to advanced content levelIntermediate to advanced
889 pages
37h 5m
English
Pearson India
Content preview from Java Programming by Pearson
Inheritance in Java • 221
{
void display()
{
System.out.println(“Hello from display of C”);
}
}
class JPS11
{
public static void main(String[] args)
{
A ref = new A();
B b = new B();
C c = new C();
ref.show();
ref.display();
ref = b;
ref.show();
ref.display();
ref = c;
ref.show();
ref.display();
}
}
OUTPUT:
Hello from show of A
Hello from display of A
Hello from show of B
Hello from display of A
Hello from show of A
Hello from display of C
Explanation: In class A, two methods, show and display, are defi ned. The function show is overridden
in class B but display is not. In the class C method, display is o ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Java Programming, 1st Edition by Pearson

Java Programming, 1st Edition by Pearson

K. Rajkumar
Object Oriented Programming Through Java by Pearson

Object Oriented Programming Through Java by Pearson

Ramesh Vasappanavara, Anand Vasappanavara, Gautam Vasappanavara
Python Programming by Pearson

Python Programming by Pearson

S.Sridhar, J. Indumathi, V.M. Hariharan

Publisher Resources

ISBN: 9781299486539