Win a copy of JDBC Workbook this week in the JDBC and Relational Databases forum
or A Day in Code in the A Day in Code forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

JDiscuss Test5 Question

 
Ranch Hand
Posts: 1026
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 4982
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I can compile the class without any problem.



Nick
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If we import the util package that works . how can a string literal "abc" be considered as an object
 
Nicholas Cheung
Ranch Hand
Posts: 4982
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
 
Thank you my well lotioned goddess! Here, have my favorite tiny ad!
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic