1.Assertions
Q: 01 Given:
8. public class test {
9. public static void main(String [] a) {
10. assert a.length == 1;
11. }
12. }
Which two will produce an AssertionError? (Choose two.)
A. java test
B. java -ea test
C. java test file1
D. java -ea test file1
E. java -ea test file1 file2
F. java -ea:test test file1
8. public class test {
9. public static void main(String [] a) {
10. assert a.length == 1;
11. }
12. }
Which two will produce an AssertionError? (Choose two.)
A. java test
B. java -ea test
C. java test file1
D. java -ea test file1
E. java -ea test file1 file2
F. java -ea:test test file1
Answer: B, E
Q: 02 Given a method that must ensure that its
parameter is not null:
11. public void someMethod(Object value) {
12. // check for null value
...
20. System.out.println(value.getClass());
21. }
11. public void someMethod(Object value) {
12. // check for null value
...
20. System.out.println(value.getClass());
21. }
What, inserted at line 12, is the appropriate way
to handle a null value?
A. assert value == null;
B. assert value != null, "value is null";
C. if (value == null) {
throw new AssertionException("value is null");
}
D. if (value == null) {
throw new IllegalArgumentException("value is null");
}
A. assert value == null;
B. assert value != null, "value is null";
C. if (value == null) {
throw new AssertionException("value is null");
}
D. if (value == null) {
throw new IllegalArgumentException("value is null");
}
Answer: D
Q: 03 Given:
23. int z = 5;
24.
25. public void stuff1(int x) {
26. assert (x > 0);
27. switch(x) {
28. case 2: x = 3;
29. default: assert false; } }
30.
31. private void stuff2(int y) { assert (y < 0); }
32.
33. private void stuff3() { assert (stuff4()); }
34.
35. private boolean stuff4() { z = 6; return false; }
23. int z = 5;
24.
25. public void stuff1(int x) {
26. assert (x > 0);
27. switch(x) {
28. case 2: x = 3;
29. default: assert false; } }
30.
31. private void stuff2(int y) { assert (y < 0); }
32.
33. private void stuff3() { assert (stuff4()); }
34.
35. private boolean stuff4() { z = 6; return false; }
Which statement is true?
A. All of the assert statements are used appropriately.
B. Only the assert statement on line 31 is used appropriately.
C. The assert statements on lines 29 and 31 are used appropriately.
D. The assert statements on lines 26 and 29 are used appropriately.
E. The assert statements on lines 29 and 33 are used appropriately.
F. The assert statements on lines 29, 31, and 33 are used appropriately.
G. The assert statements on lines 26, 29, and 31 are used appropriately.
A. All of the assert statements are used appropriately.
B. Only the assert statement on line 31 is used appropriately.
C. The assert statements on lines 29 and 31 are used appropriately.
D. The assert statements on lines 26 and 29 are used appropriately.
E. The assert statements on lines 29 and 33 are used appropriately.
F. The assert statements on lines 29, 31, and 33 are used appropriately.
G. The assert statements on lines 26, 29, and 31 are used appropriately.
Answer: C
Question: 04
Click the Exhibit button.
1. public class Test {
2.
3. public static void main(String [] args) {
4. boolean assert = true;
5. if(assert) {
6. System.out.println(”assert is true”);
7. }
8. }
9.
10. }
Given:
javac -source 1.3 Test.java
Click the Exhibit button.
1. public class Test {
2.
3. public static void main(String [] args) {
4. boolean assert = true;
5. if(assert) {
6. System.out.println(”assert is true”);
7. }
8. }
9.
10. }
Given:
javac -source 1.3 Test.java
What is the result?
A. Compilation fails.
B. Compilation succeeds with errors.
C. Compilation succeeds with warnings.
D. Compilation succeeds without warnings or errors.
A. Compilation fails.
B. Compilation succeeds with errors.
C. Compilation succeeds with warnings.
D. Compilation succeeds without warnings or errors.
Answer: C
05. Given two files:
1. class One {
2. public static void main(String[] args) {
3. int assert = 0;
4. }
5. }
1. class Two {
2. public static void main(String[] args) {
3. assert(false);
4. }
5. }
And the four command-line invocations:
javac -source 1.3 One.java
javac -source 1.4 One.java
javac -source 1.3 Two.java
javac -source 1.4 Two.java
1. class One {
2. public static void main(String[] args) {
3. int assert = 0;
4. }
5. }
1. class Two {
2. public static void main(String[] args) {
3. assert(false);
4. }
5. }
And the four command-line invocations:
javac -source 1.3 One.java
javac -source 1.4 One.java
javac -source 1.3 Two.java
javac -source 1.4 Two.java
What is the result?
(Choose all that apply.)
A. Only one compilation will succeed.
B. Exactly two compilations will succeed.
C. Exactly three compilations will succeed.
D. All four compilations will succeed.
E. No compiler warnings will be produced.
F. At least one compiler warning will be produced.
A. Only one compilation will succeed.
B. Exactly two compilations will succeed.
C. Exactly three compilations will succeed.
D. All four compilations will succeed.
E. No compiler warnings will be produced.
F. At least one compiler warning will be produced.
Answer:
-> B and F are correct. Class One will compile (and issue a warning) using the 1.3 flag, andclass Two will compile using the 1.4 flag.
-> A, C, D, and E are incorrect based on the above. (Objective 2.3)
-> B and F are correct. Class One will compile (and issue a warning) using the 1.3 flag, andclass Two will compile using the 1.4 flag.
-> A, C, D, and E are incorrect based on the above. (Objective 2.3)
06. Which are true? (Choose all that apply.)
A. It is appropriate to use assertions to validate arguments to
methods marked public.
B. It is appropriate to catch and handle assertion errors.
C. It is NOT appropriate to use assertions to validate command-line arguments.
D. It is appropriate to use assertions to generate alerts when you reach code that should notbe reachable.
E. It is NOT appropriate for assertions to change a program’s state.
B. It is appropriate to catch and handle assertion errors.
C. It is NOT appropriate to use assertions to validate command-line arguments.
D. It is appropriate to use assertions to generate alerts when you reach code that should notbe reachable.
E. It is NOT appropriate for assertions to change a program’s state.
Answer:
->C , D, and E are correct statements.
-> A is incorrect. It is acceptable to use assertions to test the arguments of private methods. B is incorrect. While assertion errors can be caught, Sun discourages you from doing so.
->C , D, and E are correct statements.
-> A is incorrect. It is acceptable to use assertions to test the arguments of private methods. B is incorrect. While assertion errors can be caught, Sun discourages you from doing so.
Hi Can you send me the document to vishwakar@gmail.com
ReplyDeleteHi Can you please send me latest scjp dumps to chaithanya.veeravelli@gmail.com
ReplyDeletehai ,
ReplyDeletecan u plz send the latest OCJP dumps to madhucse.snm@gmail.com.Can we expect the questions from dumps...plz help us in this
Please share the OCJP 1.6 dumps to sadurga@gmail.com
ReplyDeletecan you send me the latest dump files...m about to take the test
ReplyDeletesikandar89dubey@gmail.com
Please send me scjp 1.6 full dumps to yogeshmahindrakar2411@gmail.com
ReplyDeleteHi
ReplyDeleteI am planning to take the scjp exam this month end. can anyone provide me the lastest dump which are required to score in the exam on my email selvaji_mca@rediffmail.com
Thanks
Selva.c
i think v should use certification dumps for practice the question and not memorizing it for exam.. dumps are the collection of question from actual exam.
ReplyDeleteHi,
ReplyDeletePlease send me latest dumps for SCJP 1.6 to supriyasmg@yahoo.co.in
Hi,
ReplyDeleteIf anyone is having latest dumps for OCJP please send me at go.agam@gmail.com
Thanks in Anticipation
Regards
Agam Gore
Hi Can you please send me latest scjp dumps to Jayaram.Namburaj@yahoo.com
ReplyDeleteHi Can you please send me latest scjp dumps to rac293@yahoo.co.in
ReplyDeletecan anyone please send me lastest scjp dumps to haqshaid@gmail.com
ReplyDeleteSend plz to ... sayco_nesta@yahoo.com
ReplyDeletehi can anyone please send the latest dumps to kartik_67@rocketmail.com
ReplyDeleteanybody please send ocjp latest dumps for the mail-id sathyaraj00190@yahoo.in
ReplyDeleteHi
ReplyDeleteI am planning to take the OCJP, OCWD Certification exam this month end. can anyone provide me the latest dump which are required to score in the exam on my email ankit.grover84@gmail.com
Thanks
Ankit
hii any one can send SCJP 6 latest dump files to this mail id chander.1256@gmail.com
ReplyDeleteHi
ReplyDeleteCould someone please send me the SCJP latest dump file to mastmauladude@gmail.com. thanks
Hi
ReplyDeleteAm planning to take the scjp exam this month end. can anyone provide me the lastest dump to my email sanjaysam19@gmail.com
Thanks in advance..!!
Hi,I wish you all the best.
DeleteCan you please forward ocjp dumps to me if you have and my mail id is muraliy.kmm@gmail.com, I am planning for next month..
thanks in advance.
can any one send me ocjp dumps on shrikanttupe9@gmail.com
ReplyDeleteHi ,Can anyone please send the latest SCJP 6 dumps . @ chandan.ece.21@gmail.com
ReplyDeleteThanks in Advance
hi send ocjp 1.6 duumps to murali.040689@gmail.com
ReplyDeletesend ocjp 1.6 dumps to valavanp@gmail.com
ReplyDeleteThanks in advance
Please send latest dumps to valavanp@gmail.com
ReplyDeleteThanks in advance
HI All,
ReplyDeleteAny any one can send OCJP 6 latest dumps to my mail id muraliy.kmm@gmail.com
Thanks in Advance
HI....
ReplyDeleteI'm going to take ocjp exam so plz anybody send me dumps to my mail id- spprasad7@gmail.com
Latest OCJP Vaild Dumps(April 2013):
Deletehttp://avstudentz.blogspot.in/2013/04/ocjp-6-latest-dumps.html
Latest OCJP Vaild Dumps(April 2013):
ReplyDeletehttp://avstudentz.blogspot.in/2013/04/ocjp-6-latest-dumps.html
Hi,
ReplyDeleteanyone please send me the latest OCJP dumps to my mail id purfiraj@gmail.com.
Thanks in advance
Hai,
ReplyDeleteanyone please send me the latest ocjp dumps to my mail id saiki.cool@gmail.com
hey..!!
ReplyDeletecan u please send the dumps to nemishnigam91@gmail.com
i've got my exam i a week..it would be really helpful..:)
thanks.. :)
Hi,
ReplyDeletePlease send me the latest ocjp dumps to me summy.takkar@gmail.com
Please send me latest dumps to me summy.takkar@gmail.com
ReplyDeletedhyan99@gmail.com pls frwrd dumps whoever got it.
ReplyDeletehai can any one send me scjp dump 1.6 to masetty.manikishore@gmail.com
ReplyDeletepls send OCPJP 6 dumps to: csccdp1234@gmail.com
ReplyDeletePLS SEND ME THE OCJP6 DUMPS TO meenupaddhu@yahoo.com
ReplyDeletepls send OCPJP 6 dumps to: kirany2k@gmail.com
ReplyDeletePLS SEND ME THE OCJP6 DUMPS TO kirany2k@gmail.com
ReplyDelete