File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes where is the Object o1 come from? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "where is the Object o1 come from?" Watch "where is the Object o1 come from?" New topic
Author

where is the Object o1 come from?

Megan Lion
Greenhorn

Joined: Mar 02, 2002
Posts: 7
Given the following classes which of the following will compile without error?
interface IFace{}
class CFace implements IFace{}
class Base{}
public class ObRef extends Base{
public static void main(String argv[]){
ObRef ob = new ObRef();
Base b = new Base();
Object o1 = new Object();
IFace o2 = new CFace();
}
}
1) o1=o2;
2) b=ob;
3) ob=b;
4) o1=b

correct answer is 1,2,4, i can not understand why the choice 1 and 4 is correct.Where the Object 01 come from ,what mean ?
Corey McGlone
Ranch Hand

Joined: Dec 20, 2001
Posts: 3271
Originally posted by cclion:
Where the Object 01 come from?

The variable o1 comes from the line:

Since o1 is of type Object, any reference to an object in Java can be assigned to it because all classes either implicity or explicity extend Object.
Corey


SCJP Tipline, etc.
Valentin Crettaz
Gold Digger
Sheriff

Joined: Aug 26, 2001
Posts: 7610
cclion,
Please, read the Javaranch Naming Policy and change your publicly displayed name to comply with our unique rule. Thank you for your cooperation.


SCJP 5, SCJD, SCBCD, SCWCD, SCDJWS, IBM XML
[Blog] [Blogroll] [My Reviews] My Linked In
Nazmul Huda Sarkar
Ranch Hand

Joined: Feb 01, 2002
Posts: 317
Hi cclion
the object is o1 not 01....and any object or interface can be assigned to Object type..here o1
in the exam read question very carefully..


Nazmul<br />SCJP,SCWCD,IBM OOAD with UML
Valentin Crettaz
Gold Digger
Sheriff

Joined: Aug 26, 2001
Posts: 7610
cclion,
you can click on the following link
http://www.javaranch.com/cgi-bin/ubb/ultimatebb.cgi?ubb=edit_my_profile
and change your publicly displayed name (the first textfield). Thank you for your cooperation.
Megan Lion
Greenhorn

Joined: Mar 02, 2002
Posts: 7
thank Corey, thank Nazmul, i see .
R K Singh
Ranch Hand

Joined: Oct 15, 2001
Posts: 5371
Object is the base class for all Java classes hence can hold refernce to any object.


"Thanks to Indian media who has over the period of time swiped out intellectual taste from mass Indian population." - Chetan Parekh
Valentin Crettaz
Gold Digger
Sheriff

Joined: Aug 26, 2001
Posts: 7610
lion,
I'm sorry to come back again and again with this "name" thing, but yours still does not comply with our rule which specifies that it should be composed of your first name, a space and your last name.
Please do the necessary. Thank you for your cooperation.
Megan Lion
Greenhorn

Joined: Mar 02, 2002
Posts: 7
I am sorry to take you so much trouble,dear Valentin Crettaz.Thanks for your patience,thank you very much.
I have changed my name ,does it right now ?!
Valentin Crettaz
Gold Digger
Sheriff

Joined: Aug 26, 2001
Posts: 7610
That's perfect Megan
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: where is the Object o1 come from?