aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes JDiscuss Test5 Question 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 "JDiscuss Test5 Question" Watch "JDiscuss Test5 Question" New topic
Author

JDiscuss Test5 Question

Vishnu Prakash
Ranch Hand

Joined: Nov 15, 2004
Posts: 1026
Which of the following are valid code fragments:

Options

Select 1 correct option.

1. new Object[]{ "aaa", new Object(), new Vector(), 10};
2. new Object[]{ "aaa", new Object(), new Vector(), {} };
3. new Object[]{ "aaa", new Object(), new Vector(), new String[]{""} };
4. new Object[1]{ new Object() };
5. None of these is valid.


I found this question in JDiscuss Test5.

The answer given is option3. But thats giving an compiler error saying Vector class not allowed.
I think the correct answer is option 5.


Please give your suggestions.


Servlet Spec 2.4/ Jsp Spec 2.0/ JSTL Spec 1.1 - JSTL Tag Documentation
Nicholas Cheung
Ranch Hand

Joined: Nov 07, 2003
Posts: 4982
I can compile the class without any problem.



Nick


SCJP 1.2, OCP 9i DBA, SCWCD 1.3, SCJP 1.4 (SAI), SCJD 1.4, SCWCD 1.4 (Beta), ICED (IBM 287, IBM 484, IBM 486), SCMAD 1.0 (Beta), SCBCD 1.3, ICSD (IBM 288), ICDBA (IBM 700, IBM 701), SCDJWS, ICSD (IBM 348), OCP 10g DBA (Beta), SCJP 5.0 (Beta), SCJA 1.0 (Beta), MCP(70-270), SCBCD 5.0 (Beta), SCJP 6.0, SCEA for JEE5 (in progress)
alchemist here
Greenhorn

Joined: Jul 06, 2005
Posts: 1
If we import the util package that works . how can a string literal "abc" be considered as an object
Nicholas Cheung
Ranch Hand

Joined: Nov 07, 2003
Posts: 4982
how can a string literal "abc" be considered as an object

A string literal itself is an object, even you dont use new String("abc").

Nick
Steve Morrow
Ranch Hand

Joined: May 22, 2003
Posts: 657

http://www.javaranch.com/journal/200409/Journal200409.jsp#a1
 
Consider Paul's rocket mass heater.
 
subject: JDiscuss Test5 Question