File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes A Question From TestLab Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "A Question From TestLab" Watch "A Question From TestLab" New topic

A Question From TestLab

Neil Muya
Ranch Hand

Joined: Oct 26, 2009
Posts: 30
Which of the following statements are true?(Choose three)

This is the box that i should checked.

"Interface "is-a" java.lang.Object"

This was the explanation:
Answer-I is correct, because any object, which has an
interface-reference, can be implicitly casted to
a java.lang.Object reference, without doing any explicit cast.

For what I know an interface does not extend the Object class..

hmmm or maybe i did not get the question right.

Hope you guys can help me with this thank you!
Neha Daga
Ranch Hand

Joined: Oct 30, 2009
Posts: 504
I read this in K&B:
In java everything that is not a primitive is an Object.

SCJP 1.6 96%
Devaka Cooray
ExamLab Creator

Joined: Jul 29, 2008
Posts: 3930

Neil Muya wrote:A Question From TestLab

TestLab ?

Author of ExamLab ExamLab - a free SCJP / OCPJP exam simulator
What would SCJP exam questions look like? -- Home -- Twitter -- How to Ask a Question
Simran Dass
Ranch Hand

Joined: Jan 09, 2010
Posts: 183

A small example for the explanation given in the EXAMLAB sb = new String();
Object o = sb;

Hope now you get it
Rohan Kayan
Ranch Hand

Joined: Sep 17, 2004
Posts: 123
It is still not clear to me ,

In above example String "is-a" an Object that is why the assignment in second line worked. But how can we say that Interface "IS-A" java.lang.Object ?

SCWCD 1.4, SCJP 1.4
raj malhotra
Ranch Hand

Joined: Feb 22, 2007
Posts: 288
Try this:
rushikesh sawant
Ranch Hand

Joined: Dec 22, 2009
Posts: 65
All objects implicitly extends java.lang.Object.
Interface defines a set of methods that its implementing classes must implement.

String class IS-A Serializable.
string class' object is-a serializable.
so, a particular object IS-A particular interface.
hence, Interface IS-A Object.

it is a logical IS-A relationship.

SCJP 5.0 100%
Parambir Singh
Ranch Hand

Joined: Sep 05, 2004
Posts: 40

If an object of type A can be cast to type B, we can say that 'A is a B'.

E.g. Object o = new String();
Hence, String "is a" Object

Serializable s = new String();
Hence, String "is a" Serializable

And, Object o = s;
Hence Serializable "is a" Object

And in the last statement, s can be an object implementing any interface, therefore Interface "is a" Object is true.

Rohan Kayan
Ranch Hand

Joined: Sep 17, 2004
Posts: 123
I think this one is a better example to understand that Interfaces are compiled as .class files and every classes are itself an Object in Java , that is why Interfaces "IS-A" java.lang.Object
I agree. Here's the link:
subject: A Question From TestLab
It's not a secret anymore!