Skip to Main Content
Java
book

Java

by Michael Sikora
January 2003
Beginner to intermediate content levelBeginner to intermediate
150 pages
7h 28m
English
Morgan Kaufmann
Content preview from Java
[] 5.3 Abstract Classes and Methods
5 7
resulting in
emp2 is Employee@f97
Clearly, we would want to override toString in the Employee class to provide more meaningful
output. The code shows an overridden toString method that we might add to the Employee
class.
toString
1 public String toString() {
2 return "Employee[" + empNumber + ", " + name + ",
3 + salary + "]" ;
4 }
toString
The statement
System. out. println(emp2, toString ( ) ) ;
will now output
Employee[2, Sim, 15000]
5.2.4
instanceof Operator
The instanceof operator is used to check if an object is an instance of the specified class or
subclass of ...
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

Java Programming

Poornachandra Sarang
Java Programming

Java Programming

Hari Mohan Pandey
JAVA Programming

JAVA Programming

K. Rajkumar
Java 9 for Programmers

Java 9 for Programmers

Paul J. Deitel, Harvey Deitel

Publisher Resources

ISBN: 9781558609099