This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
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
 
jQuery in Action, 2nd edition
 
subject: JDiscuss Test5 Question
 
Similar Threads
just to share
Mock Exam Queries from JDiscuss..
Should we expect such questions?
need help to understand question
please explain the output?