0% found this document useful (0 votes)
9 views1 page

9 - PDFsam - 8. OOPs

The document contains 3 questions and answers from a SCJP exam preparation material. Question 14 asks about the output of calling a method that checks for a null or empty string with a null value passed in. The answer is A, that an exception will be thrown at runtime. Question 15 asks about overloading and passing different primitive types. The answer is C, that compilation will fail. Question 16 asks about code fragments that would produce an output of 100.

Uploaded by

ROHIT JAIN
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views1 page

9 - PDFsam - 8. OOPs

The document contains 3 questions and answers from a SCJP exam preparation material. Question 14 asks about the output of calling a method that checks for a null or empty string with a null value passed in. The answer is A, that an exception will be thrown at runtime. Question 15 asks about overloading and passing different primitive types. The answer is C, that compilation will fail. Question 16 asks about code fragments that would produce an output of 100.

Uploaded by

ROHIT JAIN
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

DURGA’s SCJP Material

Q: 14 Given:

11. public static void test(String str) {


12. if (str == null | str.length() == 0) {
13. System.out.println("String is empty");
14. } else {
15. System.out.println("String is not empty");
16. }
17. }
And the invocation:
31. test(null);
What is the result?
A. An exception is thrown at runtime.
B. "String is empty" is printed to output.
C. Compilation fails because of an error in line 12.
D. "String is not empty" is printed to output.

Answer: A

Q: 15 Given:
12. public class Wow {
13. public static void go(short n) {System.out.println("short");}
14. public static void go(Short n) {System.out.println("SHORT");}
15. public static void go(Long n) {System.out.println(" LONG");}
16. public static void main(String [] args) {
17. Short y = 6;
18. int z = 7;
19. go(y);
20. go(z);
21. }
22. }
What is the result?
A. short LONG
B. SHORT LONG
C. Compilation fails.
D. An exception is thrown at runtime.

Answer: C

Q: 16 Click the Exhibit button.

Which three code fragments, added individually at line 29, produce the output 100? (Choose
three.)

DURGASOFT, # 202,2nd Floor,HUDA Maitrivanam,Ameerpet, Hyderabad - 500038,  040 – 64 51 27 86,


80 96 96 96 96, 9246212143 | www.durgasoft.com Page 9

You might also like