• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

What will be in Real SCJP Exam

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

I am a new member.I have few doubts on real scjp exam.
if the question pattern is like,


Q. Consider the following lines of code:

Integer i = new Integer(42);
Long ln = new Long(42);
Double d = new Double(42.0);

Which of the following options are valid?

???<Select 2 correct options >

a i == ln;
b ln == d;
c i.equals(d);
d d.equals(ln);
e ln.equals(42);


Will it be there in the question that how many correct answer(???) needs to be selected.
 
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, in the SCJP 1.4 and 5.0 exams you will be told the number of correct options out of those given. In the SCJP 1.2 exam (if it is still offered), you will not be told.
[ November 30, 2005: Message edited by: Barry Gaunt ]
 
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
correct answer??
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Answer is c and d.

== -> cant be used to compare two different types. so a and b are wrong.
.equals() -> can be used to compare with an object. so e is wrong.

Regards,
G. Vinodh Kumar.
 
author
Posts: 9050
21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The *real* exam will tell you how many correct answers a question has. Many mock exams (including ours) say something like "choose all that apply." I can't speak for other mock question writers, but we do that to make the questions harder.
 
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,

Here the Question is which options are valid --not which options output true

am I correct(correct me if not),In this case C,D are correct answeres

If the question is Which outputs true...

Then C,D doesn't give true.

am i rite,plz clarify ..


Thanks in advance
 
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes Sridhar, options C & D will give "false" as output.B'coz they won't
pass instanceof test.

 
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In Java 1.5 option will give true.

for eg,output for the snippet will result in both true.
equals() of the wrapper classes can take primitive value also.
--------------------------------------------

public class Test100
{
public static void main(String cmd[])
{
int i = 42;
Integer in = new Integer(42);

System.out.println(in.equals(i));

System.out.println(new Long(42).equals(42L));
}
}
----------------------------------------------------
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic