OCA PREP ASSESSMENT-4
1. What will be the result of compiling and executing Test class?
A. 5321
B. Compilation error
C. Prints 5 once
D. Prints 5 in an infinite loop
2. On executing Counter class, how many Counter objects are created in the memory?
A. 3
B. 1
C. 4
D. 2
3. Which of the following statement is correct about below code?
A. Compiles successfully and prints "Bye"
B. Compiles successfully and prints 100 in an infinite loop
C. 100 Bye
D. Unreachable code compilation error
4. What will be the result of compiling and executing Test class?
A. 32
B. 22
C. Compilation error in main method
D. An exception is thrown at runtime
5. What will be the result of compiling and executing Test class?
A. 0
B. 2
C. 3
D. 1
6. Which of the method of String class is used to remove leading and trailing white
spaces?
A. ltrim( )
B. trim( )
C. rtrim( )
D. trimBoth( )
7. For the code below, what should be the name of java file?
A. helloworld.java
B. Hello.java
C. HelloWorld.java
D. helloWorld.java
8. What will be the result of compiling and executing Test class?
A. NullPointerException is thrown at runtime
B. Compilation error
C. static method
D. None of the above
9. What will be the result of compiling and executing Test class?
A. 65 66
B. 123
C. AB
D. Compilation error
10. What will be the result of compiling and executing Test class?
A. 20
B. 33
C. 30
D. An exception is thrown at runtime
11. What will be the result of compiling and executing Test class?
A. FFFFF
B. TTTFT
C. FTFFF
D. NullPointerException is thrown at runtime
12. DateTimeFormatter is defined inside which package?
A. java.time.format
B. java.time
C. java.text
D. java.util
13. What will be the result of compiling and executing Test class?
A. Compilation error
B. true
C. false
D. None
14. Which of the following statement is correct?
A. Code compiles successfully but throws runtime exception
B. It will print any int value between 0 and 23
C. It will print any int value between 1 and 24
D. Code fails to compile
15. Wrapper classes are defined in which of the following package?
A. java.lang
B. java.io
C. java.util
D. default package
16. What will be the result of compiling and executing Test class?
A. [Array,List]
B. Compilation error
C. An exception is thrown at runtime
D. [Array,null,List,null]
17. How many String objects are there in the HEAP memory, when control is at Line 9?
A. 3
B. 2
C. 4
D. 5
18. Which of the following is the correct package declaration to declare Test class in
com.exam.oca.Test
A. package com.exam.oca.Test;
B. package com.exam.oca.*;
C. Package com.exam.oca;
D. package com.exam.oca;
19. What will be the result of compiling and executing Test class?
A. [true]
B. NullPointerException is thrown at runtime
C. [false]
D. []
20. What will be the result of compiling and executing Test class?
A. Program terminates abruptly
B. "Main ends!!!" is printed and program terminates successfully
C. "Exception!!!" is printed and program terminates successfully
D. "Exception!!!" is printed and program terminates abruptly
21. What will be the result of compiling and executing Test class?
A. true:true
B. null:null
C. false:false
D. NullPointerException is thrown at runtime
22. What will be the result if Test class is executed by below command? java Test 10
A. THREE
B. TWO
C. ONE
D. Compilation error
23. What will be the result of compiling and executing Wall class?
A. green
B. null
C. NullPointerException
D. Compilation error
24. What will be the result of compiling and executing Test class?
A. Runtime exception
B. compilation error
C. true
D. false
25. What will be the result of compiling and executing Test class?
A. 3
B. 2
C. Compilation error
D. 0
26. Which of the following statement is correct?
A. Code compiles successfully but throws Runtime exception
B. Code fails to compile
C. It will print any int value between 1 and 60
D. It will print any int value between 0 and 59
27. What will be the result of compiling and executing Test class?
A. [5,10]
B. An exception is thrown at runtime
C. Compilation error
D. [50,50]
28. What will be the result of compiling and executing Test class?
A. 1947-08-14T23:59:59
B. 1947-08-14T23:59:59.999999999
C. 1947-08-14T23:59:59.0
D. 1947-08-14T23:59:59.999
29. What will be the result of compiling and executing Test class?
A. 01-11-12
B. 01-11-11
C. 11-11-11
D. 11-11-12
30. On execution, does Test class print "HELLO" on to the console?
A. No,HELLO is not printed on the console
B. Yes,HELLO is printed on to the console
C. No,Hello is not printed on the console
D. Yes,Hello is printed on to the console