SCJP MATERIAL
  <<Back To SCJP Material Main Page

Q: 01 Given:
11. public class Test {
12. public static void main(String [] args) {
13. int x = 5;
14. boolean b1 = true;
15. boolean b2 = false;
16.
17. if ((x == 4) && !b2 )
18. System.out.print("1 ");
19. System.out.print("2 ");
20. if ((b2 = true) && b1 )
21. System.out.print("3 ");
22. }
23. }

What is the result?
A. 2
B. 3
C. 1 2
D. 2 3
E. 1 2 3
F. Compilation fails.
G. An exception is thrown at runtime.

Answer: D

Q: 02 Given the command line java Pass2 and:
15. public class Pass2 {
16. public void main(String [] args) {
17. int x = 6;
18. Pass2 p = new Pass2();
19. p.doStuff(x);
20. System.out.print(" main x = " + x);
21. }
22.
23. void doStuff(int x) {
24. System.out.print(" doStuff x = " + x++);
25. }
26. }
What is the result?
A. Compilation fails.
B. An exception is thrown at runtime.
C. doStuff x = 6 main x = 6
D. doStuff x = 6 main x = 7
E. doStuff x = 7 main x = 6
F. doStuff x = 7 main x = 7                   
 
   Answer: B

Q: 03 Given:
13. public class Pass {
14. public static void main(String [] args) {
15. int x = 5;
16. Pass p = new Pass();
17. p.doStuff(x);
18. System.out.print(" main x = " + x);
19. }
20.
21. void doStuff(int x) {
22. System.out.print(" doStuff x = " + x++);
23. }
24. }
What is the result?
A. Compilation fails.
B. An exception is thrown at runtime.
C. doStuff x = 6 main x = 6
D. doStuff x = 5 main x = 5
E. doStuff x = 5 main x = 6
F. doStuff x = 6 main x = 5
Answer: D

Question: 04
Given:
42. public class ClassA {
43. public int getValue() {
44.int value=0;
45. boolean setting = true;
46. String title=”Hello”;
47. if (value || (setting && title == “Hello”)) { return 1; }
48. if (value == 1 & title.equals(”Hello”)) { return 2; }
49. }
50. }
And:
70. ClassA a = new ClassA();
71. a.getValue();
What is the result?
A. 1
B. 2
C. Compilation fails.
D. The code runs with no output.
E. An exception is thrown at runtime.
Answer: C

5. Given:
class Hexy {
public static void main(String[] args) {
Integer i = 42;
String s = (i<40)?"life":(i>50)?"universe":"everything";
System.out.println(s);
} }
What is the result?
A. null
B. life
C. universe
D. everything
E. Compilation fails.
F. An exception is thrown at runtime.
Answer:
-> D is correct. This is a ternary nested in a ternary with a little unboxing thrown in.
Both of the ternary expressions are false.
-> A, B, C, E, and F are incorrect based on the above.

6. Given:
1. class Example {
2. public static void main(String[] args) {
3. Short s = 15;
4. Boolean b;
5. // insert code here
6. }
7. }
Which, inserted independently at line 5, will compile? (Choose all that apply.)

A. b = (Number instanceof s);
B. b = (s instanceof Short);
C. b = s.instanceof(Short);
D. b = (s instanceof Number);
E. b = s.instanceof(Object);
F. b = (s instanceof String);
Answer:
->  B and D correctly use boxing and instanceof together.
-> A is incorrect because the operands are reversed. C and E use incorrect instance   of syntax. F is wrong because Short isn't in the same inheritance tree as String.

Q: 01 Given:
11. public class Test {
12. public static void main(String [] args) {
13. int x = 5;
14. boolean b1 = true;
15. boolean b2 = false;
16.
17. if ((x == 4) && !b2 )
18. System.out.print("1 ");
19. System.out.print("2 ");
20. if ((b2 = true) && b1 )
21. System.out.print("3 ");
22. }
23. }

What is the result?
A. 2
B. 3
C. 1 2
D. 2 3
E. 1 2 3
F. Compilation fails.
G. An exception is thrown at runtime.

Answer: D

Q: 02 Given the command line java Pass2 and:
15. public class Pass2 {
16. public void main(String [] args) {
17. int x = 6;
18. Pass2 p = new Pass2();
19. p.doStuff(x);
20. System.out.print(" main x = " + x);
21. }
22.
23. void doStuff(int x) {
24. System.out.print(" doStuff x = " + x++);
25. }
26. }
What is the result?
A. Compilation fails.
B. An exception is thrown at runtime.
C. doStuff x = 6 main x = 6
D. doStuff x = 6 main x = 7
E. doStuff x = 7 main x = 6
F. doStuff x = 7 main x = 7                   
 
   Answer: B

Q: 03 Given:
13. public class Pass {
14. public static void main(String [] args) {
15. int x = 5;
16. Pass p = new Pass();
17. p.doStuff(x);
18. System.out.print(" main x = " + x);
19. }
20.
21. void doStuff(int x) {
22. System.out.print(" doStuff x = " + x++);
23. }
24. }
What is the result?
A. Compilation fails.
B. An exception is thrown at runtime.
C. doStuff x = 6 main x = 6
D. doStuff x = 5 main x = 5
E. doStuff x = 5 main x = 6
F. doStuff x = 6 main x = 5
Answer: D

Question: 04
Given:
42. public class ClassA {
43. public int getValue() {
44.int value=0;
45. boolean setting = true;
46. String title=”Hello”;
47. if (value || (setting && title == “Hello”)) { return 1; }
48. if (value == 1 & title.equals(”Hello”)) { return 2; }
49. }
50. }
And:
70. ClassA a = new ClassA();
71. a.getValue();
What is the result?
A. 1
B. 2
C. Compilation fails.
D. The code runs with no output.
E. An exception is thrown at runtime.
Answer: C

5. Given:
class Hexy {
public static void main(String[] args) {
Integer i = 42;
String s = (i<40)?"life":(i>50)?"universe":"everything";
System.out.println(s);
} }
What is the result?
A. null
B. life
C. universe
D. everything
E. Compilation fails.
F. An exception is thrown at runtime.
Answer:
-> D is correct. This is a ternary nested in a ternary with a little unboxing thrown in.
Both of the ternary expressions are false.
-> A, B, C, E, and F are incorrect based on the above.

6. Given:
1. class Example {
2. public static void main(String[] args) {
3. Short s = 15;
4. Boolean b;
5. // insert code here
6. }
7. }
Which, inserted independently at line 5, will compile? (Choose all that apply.)

A. b = (Number instanceof s);
B. b = (s instanceof Short);
C. b = s.instanceof(Short);
D. b = (s instanceof Number);
E. b = s.instanceof(Object);
F. b = (s instanceof String);
Answer:
->  B and D correctly use boxing and instanceof together.
-> A is incorrect because the operands are reversed. C and E use incorrect instance   of syntax. F is wrong because Short isn't in the same inheritance tree as String.

  <<Back To SCJP Material Main Page



freshers jobs | fresher jobs | freshers job | fresher job | fresher it jobs | sap fresher jobs | jobs for fresher | jobs for freshers | it jobs for freshers | abap fresher jobs | net jobs for freshers | net fresher jobs | net freshers jobs | freshers job sites | fresher job openings | software jobs for freshers | fresher jobs bangalore | hr jobs for freshers | software testing jobs for freshers | fresher jobs india | fresher jobs chennai | fresher it job | freshers it jobs | mba fresher jobs | hr fresher jobs | fresher jobs in india | networking jobs for freshers | testing jobs for freshers | job for fresher | oracle fresher jobs | mca fresher jobs | sap freshers jobs | jobs for mca freshers | fresher jobs hyd | freshers software jobs | it job for freshers | fresher job sites | jobs for mba freshers | freshers job it | hot jobs for freshers | job for freshers | testing fresher jobs | mainframe fresher jobs | jobs for freshers sap | fresher jobs at | fresher jobs usa | jobs for freshers at | jobs for freshers usa | freshers jobs at | freshers jobs usa | tech freshers jobs | net freshers job | software fresher jobs | job opportunities for freshers | jobs for freshers in usa | job vacancies for freshers | jobs mumbai fresher | it jobs for fresher | freshers job openings | job openings for freshers | it jobs for freshers in | freshers jobs bangalore | freshers job india | freshers jobs india | jobs in pune for freshers | jobs for fresher in | fresher jobs in usa | net fresher jobs in | fresher jobs in | fresher job in usa | jobs for freshers in | qa jobs for freshers | fresher jobs in dubai | freshers jobs in usa | job opening for freshers | hr freshers job | freshers job in usa | job openings for freshers in | fresher it jobs in | freshers it jobs in | job for fresher in | job for freshers in | testing jobs for freshers in | sap jobs for freshers in | sap freshers jobs in | sap fresher jobs in | mba freshers jobs | jobs for freshers in delhi | jobs for freshers in mumbai | freshers jobs in delhi | fresher jobs in mumbai | fresher jobs in bangalore | fresher jobs in delhi | net jobs for freshers in | fresher jobs in hyderabad | mba freshers job | freshers job in bangalore | fresher hr jobs in | fresher job in | jobs freshers in | finance jobs for freshers | hr jobs for freshers in | jobs in dubai for freshers | fresher it jobs in bangalore | freshers job in india | freshers job in | software jobs for freshers in | mba fresher job | fresher software jobs in | software testing jobs for freshers in | freshers jobs in mumbai | fresher jobs in chennai | mba fresher jobs in | mba finance fresher jobs | jobs for mba freshers in | jobs for mba fresher | mba freshers jobs in | fresher jobs hyderabad | hr freshers jobs | fresher jobs in pune | freshers jobs in pune | freshers jobs in chennai | jobs for mba finance fresher | freshers job in chennai | jobs for mba finance freshers | finance fresher jobs | jobs for freshers in hyderabad | freshers jobs in hyderabad | jobs for freshers in bangalore | freshers jobs in india | jobs for freshers in chennai | jobs for freshers in india | instrumentation jobs for freshers | freshers jobs in bangalore | engineering jobs for freshers in | job for mba fresher | mechanical fresher jobs | mca freshers jobs | jobs for bca freshers | b tech freshers jobs | sap jobs for fresher | sap abap fresher jobs | job sites for freshers | fresher | jobs | bpo jobs | freshers | careers freshers | freshers it | it jobs | fresher world | mba jobs | j2ee jobs | fresher recruitment | call center jobs | testing jobs | finance jobs | call centre jobs | networking jobs | wipro jobs | hyderabad jobs | chennai jobs | fresher opening | pune jobs | telecom jobs | fresher openings | banglore jobs | bangalore jobs | mca jobs | tcs jobs | kolkata jobs | it fresher | mba fresher | fresher india | gurgaon jobs | hr jobs | noida jobs | india jobs | mumbai jobs | fresh graduates | delhi jobs | freshers recruitment | consultant jobs | engineer jobs | engineering jobs | sap jobs | parttime job | walkin jobs | internet jobs | data entry jobs | jobs career | local jobs | online jobs | parttime jobs | online part time job | technical support jobs | net jobs | jobs at | software jobs | website jobs

Home   |   About Us   |   Contact Us
Copyright @ durgasoft.com