aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Certification4Career SCJP Mock Exam Errors?? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Certification4Career SCJP Mock Exam Errors??" Watch "Certification4Career SCJP Mock Exam Errors??" New topic
Author

Certification4Career SCJP Mock Exam Errors??

Lucy Das
Greenhorn

Joined: Jul 14, 2002
Posts: 8
Hi all,
The following questions are from Certification4Careers SCJP exams
I doubt some of the answers... your inputs will be greatly appreciated.Thanks in advance.
Exam#1
29. An inner class created inside a method can access
A. Any local variables of a method that contain an inner class.
B. Any instance variables of the enclosing class
C. Any final variables of the enclosing class or a method that contain an inner class.
D. None of the above
Ans is C. Me thinks its B,C
32. Please select invalid statement(s) for a thread
A. You can restart a dead thread
B. You can't call the methods of a dead thread
C. Both of the above
D. None of the above
The ans. is D. Isn't A invalid? I didn't think you could restart a dead thread.
38. Please select true statement for prefix operator(++x/--x).
A. The prefix operator(++x/--x) evaluates the value of the operand after increment/decrement operation.
B. The prefix operator(++x/--x) evaluates the value of the operand before increment/decrement operation.
C. Both A and B
D. None of the above
Ans is A. Am I missing something here? I thought it would be B.
65. 'null' is valid java type.
A. True
B. False
The answer is A. I guess the wording is unclear. -
How can null be a type?
-------------
SCJP Mock Exam 2
13. Consider following code:
public class OuterClass{
class InnerClass{
}
public void innerClassDemo(){
//Explicit instance of InnerClass
}
}
In above example, how can you explicitly create an instance of InnerClass?
A. InnerClass i=InnerClass();
B. InnerClass i=OuterClass.InnerClass();
C. InnerClass i=new OuterClass ().new InnerClass();
D. OuterClass.InnerClass i=new OuterClass.InnerClass();
Ans. is C,D; I picked C and that too I think it should be
OuterClass.InnerClass i = new OuterClass().new InnerClass();
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
#29, #32 pass (for now)
#38 For prefix ++x(--x) the increment(decrement) is done first and then the result is used in the computation.
#65 null is a type, it's the type of the literal constant null.
#13 C, D both compile and run. In fact InnerClass i = new InnerClass(); does the same trick. Your version would also work.
Please do not post so many questions in one go, someone will post a complete exam soon.
-Barry
[ August 10, 2002: Message edited by: Barry Gaunt ]

Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
zarina mohammad
Ranch Hand

Joined: Jun 26, 2002
Posts: 104
public class OuterClass{
class InnerClass{
}
public void innerClassDemo(){
//Explicit instance of InnerClass
}
}
In above example, how can you explicitly create an instance of InnerClass?
A. InnerClass i=InnerClass();
B. InnerClass i=OuterClass.InnerClass();
C. InnerClass i=new OuterClass ().new InnerClass();
D. OuterClass.InnerClass i=new OuterClass.InnerClass();
Ans. is C,D; I picked C and that too I think it should be
OuterClass.InnerClass i = new OuterClass().new InnerClass();

The answers C,D are correct.
Both C and D are correct As long as you are not calling the OuterClass methods in innerClassDemo()
you can only call the InnerClass methods
zarina mohammad
Ranch Hand

Joined: Jun 26, 2002
Posts: 104
29. An inner class created inside a method can access
A. Any local variables of a method that contain an inner class.
B. Any instance variables of the enclosing class
C. Any final variables of the enclosing class or a method that contain an inner class.
D. None of the above
Ans is C. Me thinks its B,C

yeah i think even B has to be included in the answer
David Poglitsch
Greenhorn

Joined: Jul 26, 2002
Posts: 16
Specifically, the following compiles:

David Poglitsch
Greenhorn

Joined: Jul 26, 2002
Posts: 16
32. Please select invalid statement(s) for a thread
A. You can restart a dead thread
B. You can't call the methods of a dead thread
C. Both of the above
D. None of the above
The ans. is D. Isn't A invalid? I didn't think you could restart a dead thread.

Someone correct me if I'm wrong, but isn't the answer C.
You CANNOT restart a dead thread, BUT
you CAN call the methods of a dead thread.
So that would mean A & B are false.
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
Thanks, you are correct David. I am using an environment BlueJ in which you can create classes, instantate them, call their methods, and inspect them without having explicitly called a main method.
Makes life a little easier...
-Barry
[ August 11, 2002: Message edited by: Barry Gaunt ]
Lucy Das
Greenhorn

Joined: Jul 14, 2002
Posts: 8
Thanks a lot everyone.
Barry - sorry for posting all the questions in one go.. I just compiled all the doubts I had relating to one specific Mock exam.
Jose Botella
Ranch Hand

Joined: Jul 03, 2001
Posts: 2120
I agree the question about the null type is ambigous.
valid type? you cannot use null as a type in a Java program.
Yes I think 32 is C.
For 29 a nuisance
An inner class declared within a method cannot access any final local variable of the same method. The variable must be declared before the declaration of the inner class itself:


SCJP2. Please Indent your code using UBB Code
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
Hi Jose,
regarding the null type, I love this piece of Java Language Specification Zen (4.1):
DRAFT
There is also a special null type, the type of the expression null, which has no
name. Because the null type has no name, it is impossible to declare a variable of
the null type or to cast to the null type. The null reference is the only possible
value of an expression of null type. The null reference can always be cast to any
reference type. In practice, the programmer can ignore the null type and just pretend
that null is merely a special literal that can be of any reference type.

-Barry
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Certification4Career SCJP Mock Exam Errors??