scjp material and questions
Friday, January 29, 2010
5:28 AM
,
0 Comments
Labels: Frequently asked in scjp exam , repeated q and a in scjp exam , scjp objects , scjp q and answers , scjp sun certification material , Sun Certified Programmer for Java 2 Platform 1.4 (CX-310-035) - SCJP
Labels: Frequently asked in scjp exam , repeated q and a in scjp exam , scjp objects , scjp q and answers , scjp sun certification material , Sun Certified Programmer for Java 2 Platform 1.4 (CX-310-035) - SCJP
Q: 17 Click the Task button.

Solution:
package alpha;
public class Alpha{
private String alpha;
public Alpha( ){ this("A") ; }
protected Alpha(String a){ alpha=a; }
}
package beta;
public class Beta extends alpha.Alpha{
private Beta(String a){ super(a); }
}
Q: 18 Given:
1. public class Target {
2. private int i = 0;
3. public int addOne(){
4. return ++i;
5. }
6. }
And:
1. public class Client {
2. public static void main(String[] args){
3. System.out.println(new Target().addOne());
4. }
5. }
Which change can you make to Target without affecting Client?
A. Line 4 of class Target can be changed to return i++;
B. Line 2 of class Target can be changed to private int i = 1;
C. Line 3 of class Target can be changed to private int addOne(){
D. Line 2 of class Target can be changed to private Integer i = 0;
Answer: D
Q: 19 Click the Task button.

Solution:
public class Single{
private static Single instance;
public static Single getInstance( ){
if(instance==null) instance = create( );
return instance;
}
protectedSingle( ) { }
staticSingle create ( ) { return new Single ( ) ; }
}
class SingleSub extends Shape{
}
Q: 20 Given:
12. public class Test {
13. public enum Dogs {collie, harrier};
14. public static void main(String [] args) {
15. Dogs myDog = Dogs.collie;
16. switch (myDog) {
17. case collie:
18. System.out.print("collie ");
19. case harrier:
20. System.out.print("harrier ");
21. }
22. }
23. }
What is the result?
A. collie B. harrier
C. Compilation fails. D. collie harrier
E. An exception is thrown at runtime.
Answer: D
Q: 21 Click the Exhibit button.
Given:
ClassA a = new ClassA();
a.methodA();
What is the result?

A. Compilation fails.
B. ClassC is displayed.
C. The code runs with no output.
D. An exception is thrown at runtime.
Answer: D
Q: 22 Click the Task button.

Solution:
public int update(int quantity,int adjust){
quantity=quantity+adjust;
return quantity;
}
public void call Update( ) {
int quant=100;
quant=update(quant,320);
System.out.println("the quantity is " +quant);
}



0 Response to "scjp material and questions"
Post a Comment