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 • 231
demo d1 = new demo();
d1 = d2;
System.out.println(d1.bx + “\t” + d1.by + “\t” +
d1.dx);
}
}
OUTPUT:
C:\JPS\ch8>javac JPS19.java
JPS19.java:28: cannot nd symbol
symbol : variable dx
location : class demo
System.out.println(d1.bx + “\t” + d1.by + “\t” + d1.dx);
^
1 error
Explanation: The class demo consists of two data members bx and by and class der_demo with just one
data member dx . When in the main function, d1 = d2 is written , only the inherited data members bx
and by are assigned to object d1 . The data member dx from d2 is not assigned to d1 . In effect, object d2
gets sliced. So ...
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