12-10 JAVAAAKASH
12-10 JAVAAAKASH
2 3 4
compilation, debugging, and execution? c. 2 2 3
a. JDK d. 3 1 6
b. JVM Answer: (d) 3 1 6
c. JRE 8. What will be the output of the following Java code snippet?
d. JIT class P
Answer: (a) JDK {
2. Which of these literals can be contained in a float data type }
variable? enum Enums extends P
a. -3.4e+050 {
b. +1.7e+308 PQR, QRS, RST, STU;
c. -3.4e+038 }
d. -1.7e+308 a) Compilation Error
Answer: (b) -3.4e+038 b) Runtime Error
3. What is BigDecimal.ONE? c) EnumNotDefined Exception
a. it is a custom-defined statement d) It runs successfully
b. it is a wrong statement Answer: (a) Compilation Error
c. it is a static variable that has a value of 1 on a scale of 0 9. When does Overloading not occur?
d. it is a static variable that has a value of 1 on a scale of 10 a. When more than a single method have the same name, yet
Answer: (c) it is a static variable that has a value of 1 on a scale of 0 different types or number of parameters and different method
4. When an expression consists of int, double, long, float, then the signature
entire expression will get promoted into a data type that is: b. When more than a single method have the same name, the same
a. float signature, but have different numbers of signature
b. double c. When more than a single method have the same signature, same
c. int name, and the same number of parameters have different types
d. long d. When more than a single method have the same name, the same
Answer: (b) double number and types of parameters, and yet different signatures
5. Which of the following operators can operate on a boolean Answer: (d) When more than a single method have the same name,
variable? the same number and types of parameters, and yet different
A. && signatures
B. == 10. What is it called when the child object also gets killed when the
C. ?: parent object is killed in the program?
D. += a. Encapsulation
a) C & B b. Association
b) A & D c. Aggregation
c) A, B & D d. Composition
d) A, B & C Answer: (d) Composition
Answer: (d) A, B & C 11. How does one identify if a compilation unit is an interface or class
6. Out of these statements, which ones are incorrect? from a .class file?
a. The Brackets () have the highest precedence a. Extension of the compilation unit
b. The equal to = operator has the lowest precedence b. Java source file header
c. The addition operator + and the subtraction operator – have an c. The class and interface cannot be differentiated
equal precedence d. The unit type must be used to postfix interface or class name
d. The division operator / has comparatively higher precedence as Answer: (b) Java source file header
compared to a multiplication operator 12. Out of these methods of the String class, which one can be used
Answer: (d) The division operator / has comparatively higher for testing the strings for equality?
precedence as compared to a multiplication operator a. isequals()
7. What will be the output of the following Java program? b. isequal()
class Output c. equals()
{ d. equal()
public static void main(String args[]) Answer: (c) equals()
{ 13. What would happen to the thread whenever the garbage
int p = 1; collection kicks off?
int q = 2; a. The garbage collection won’t happen until the running of the thread
int r = 3; b. The thread would continue its operation
p |= 4; c. The garbage collection and the thread don’t interfere with each
q >>= 1; other
r <<= 1; d. The thread would be paused while the running of the garbage
p ^= r; collection
System.out.println(q + ” ” + q + ” ” + r); Answer: (d) The thread would be paused while the running of the
} garbage collection
} 14. Out of these, which one is the correct way of calling a constructor
a. 3 3 6 that has no parameters of the superclass A by the subclass B?
a. superclass.(); c. IOException
b. super(void); d. SystemException
c. super(); Answer: (b) IllegalStateException
d. super.A(); 24. Out of the following, which one is a superclass of all the
Answer: (c) super(); exception type classes?
15. Out of these methods of the Object class, which one can clone an a. String
object? b. RuntimeExceptions
a. Object clone() c. Catchable
b. clone() d. Throwable
c. Object copy() Answer: (d) Throwable
d. copy() 25. What happens when we call two threads that have the same
Answer: (a) Object clone() priority to process simultaneously?
16. Out of these packages, which one contains an abstract keyword? a. Both of the threads will be simultaneouslyexecuted
a. java.util b. Any one of the threads can be executed first lexicographically
b. java.lang c. Itdepends on the OS
c. java.system d. There will be no execution of threads
d. java.io Answer: (c) Itdepends on the OS
Answer: (b) java.lang 26. Out of these classes, which one is used for reading strings and
17. Out of these methods, which one can be used for converting all characters in Java from the console?
the characters present in a String into an Array of characters? a. StringReader
a. both getChars() & toCharArray() b. BufferedReader
b. both charAt() & getChars() c. InputStreamReader
d. charAt() d. BufferedStreamReader
d. all of the mentioned Answer: (b) BufferedReader
Answer: (a) both getChars() & toCharArray() 27. Out of these operators, which one can be used to get the run time
18. What value is returned by the compareTo() function in case the info about an object?
invoking string happens to be greater than the compared string? a. Info
a. a value that is greater than zero b. getInfo
b. a value that is less than zero c. getinfoof
c. zero d. instanceof
d. none of the above Answer: (d) instanceof
Answer: (a) a value that is greater than zero 28. Out of these classes, which one allows a user to define their own
19. Out of these exceptions, which one is thrown by the compareTo() formatting pattern for time and dates?
method that is defined in a double wrapper? a. UsersDateFormat
a. SystemException b. ComplexDateFormat
b. ClassCastException c. SimpleDateFormat
c. IOException d. DefinedDateFormat
d. CastException Answer: (c) SimpleDateFormat
Answer: (b) ClassCastException 29. Which method can we use in an applet to output a string?
20. Where does the String Pool get stored? a. transient()
a. Metaspace b. drawString()
b. Java Stack c. print()
c. Java Heap d. display()
d. Permanent Generation Answer: (b) drawString()
Answer: (c) Java Heap 30. The public int start() returns what?
21. Out of these data members of the HttpResponse class, which a. the start index of the previous match
one is used for the storage of the response that is from an http b. the start index of the current match
server? c. the start index of the input string
a. address d. None of the above
b. status Answer: (a) the start index of the previous match
c. statusCode 31. Which one is a superclass of the ContainerEvent class out of the
d. statusResponse following?
Answer: (c) statusCode a. ComponentEvent
22. Out of these methods, which one makes the raw MIME formatted b. InputEvent
string? c. ItemEvent
a. toString() d. WindowEvent
b. getString() Answer: (a) ComponentEvent
c. parse() 32. _______ is a superclass of all the Adapter classes.
d. parseString() a. ComponentEvent
Answer: (c) parse() b. Applet
23. The remover() method throws which of these exceptions: c. InputEvent
a. ObjectNotFoundException d. Event
b. IllegalStateException Answer: (b) Applet
33. Which method in Java generates boolean random values? b. It implements the java.io.Serializable interface
a. randomBoolean() c. It provides getter and setter methods for its properties
b. nextBoolean() d. It provides us with no argument constructor
c. generateBoolean() Answer: (a) It extends the java.io.Serializable class
d. previousBoolean() 43. What does the abbreviation MVC pattern stand for?
Answer: (b) nextBoolean() a. Model View Class
34. Which class produces objects with respect to their geographical b. Mock View Class
locations? c. Mock View Controller
a. Simple TimeZone d. Model View Control
b. Date Answer: (d) Model View Control
c. Locale 44. The advantage of using the PreparedStatement in Java is:
d. TimeZone a. More memory usage
Answer: (c) Locale b. Prevents SQL injection
35. Which method is used for notifying the observer about the c. Encourages SQL injection
change in the observed object? d. Slow performance
a. notify() Answer: (b) Prevents SQL injection
b. update() 45. How does one move from some desired step to another one?
c. observed() a. logger.error
d. check() b. logger.log
Answer: (b) update() c. System.out.println
36. Which package is used to remotely invoke a method? d. breakpoints
a. java.awt Answer: (d) breakpoints
b. java.rmi 46. What would happen if the IP Address of the host can’t be
c. java.applet determined?
d. java.util a) IOException is thrown
Answer: (b) java.rmi b) The system will exit with no message
37. What are the uses of generics? c) Temporary IP Address will be assigned
a. The generics make a code more readable and optimised d) UnknownHostException is thrown
b. The generics make a code faster Answer: (d) UnknownHostException is thrown
c. The generics add stability to a code. They do so by making more 47. The storage capacity of a single cookie is:
bugs detectable at the runtime a) 4095 MegaBytes
d. The generics add stability to a code. They do so by making more b) 4095 bytes
bugs detectable at the compile time c) 2048 bytes
Answer: (d) The generics add stability to a code. They do so by d) 2048 MegaBytes
making more bugs detectable at the compile time Answer: (b) 4095 bytes
38. Which mechanism helps in the process of naming as well as 48. Which action variable helps in including a file in the JSP?
visibility control of the classes and their content? a) jsp:plugin
a. Packages b) jsp:include
b. Interfaces c) jsp:getProperty
c. Object d) jsp:setProperty
d. None of the above Answer: (b) jsp:include
Answer: (a) Packages 49. ______ file defines dependency in maven.
39. The configuration is stored in which of the file database tables: a) dependency.xml
a. .sql b) build.xml
b. .ora c) version.xml
c. .hbm d) pom.xml
d. .dbm Answer: (d) pom.xml
Answer: (c) .hbm 50. The main difference between AutoCloseable and Closeable is
40. The primary use of Files.lines(Path path) is that it: that:
a. reads the lines that are from a file as the Stream a) AutoCloseable throws IOException; Closeable throws Exception
b. reads the files that are at the path specified as the String b) AutoCloseable is an implementation; Closeable is a concept
c. counts the total number of lines for the files at the specified path c) AutoCloseable throws Exception; Closeable throws IOException
d. reads the filenames at the specified path d) AutoCloseable is a concrete class and Closeable is an interface
Answer: (a) reads the lines that are from a file as the Stream Answer: (c) AutoCloseable throws Exception; Closeable throws
41. Which keywords for the purpose of upper bound a wildcard? IOException
a. bound
b. stop
c. implements
d. extends
Answer: (d) extends
42. Out of the following statements, which one is not true about the
Java beans?
a. It extends the java.io.Serializable class