• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

What will be in Real SCJP Exam

 
Mr. mangal pandey
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • 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.
 
Barry Gaunt
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
  • 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 ]
 
xie li
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
correct answer??
 
g.vinodh kumar
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • 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.
 
Bert Bates
author
Sheriff
Posts: 8898
5
  • Mark post as helpful
  • send pies
  • 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.
 
veesam sridhar
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • 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
 
Mahendar Reddy
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes Sridhar, options C & D will give "false" as output.B'coz they won't
pass instanceof test.

 
Vijayagopalan Raveendran
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • 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));
}
}
----------------------------------------------------
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic