Documente Academic
Documente Profesional
Documente Cultură
3. Which of the following statements is NOT TRUE for the JVM heap?
Java Developer can explicitly allocate and deallocate the Heap Memory. (*)
The Heap can be managed by the Garbage Collector.
The Heap can be shared among all Java threads.
Class instance and arrays are allocated in the Heap Memory.
6. Java allows the same Java program to be executed on multiple operating systems.
True (*)
False
Section 2
7. The javac command can be used to display native code in Java
True
False (*)
8. Before we can use the jsat tool we first have to use the jps tool to obtain JVM process id
numbers.
True (*)
False
12. The class file contains the definition it inherits from the superclass.
True
False (*)
13. Which of the following from ClassLoader will load the rt.jar, the Java core clsses which are
present in the java.* package?
Extension Class Loader
Custom Class Loader
Bootstrap Class Loader (*)
Application Class Loader
14. Which of the following exceptions is thrown by the loadClass() method of ClassLoader class?
IOException
SystemException
ClassFormatError
ClassNotFoundException (*)
21. Which of the following types are primitive data types? (Choose Two)
Integer
boolean (*)
double (*)
String
22. Which of following statments are true when you create a object from class Object at runtime
as seen below. (Choose Three)
java.lang.Object obj = new java.lang.Object();
A new instance of class Object is created. (*)
Reference obj can be reassigned to any other type of object. (*)
This Object instance will not be created because you never defined class Object.
Memory is allocated for a new object, if available. (*)
26. Which of the following is not a good technique to follow when reading code written by
others?
Perform testing.
Learn the high level structure and starting point, and then figure out how it branches.
Find the author of the code and ask him how it works. (*)
Build and run the code.
Understand the constructs.
27. Why is it helpful for new programmers to read pre-written code?(Choose Two)
Understand code written by other programmers. (*)
Learn new programming techniques. (*)
It is not helpful to read code written by other programmers.
Meet new programmers.
29. Reading great code is just as important for a programmer as reading great books is for a
writer. True or false?
True (*)
False
30. Which of the following statements is false?
In an Array you need to know the length and the current number of elements stored.
An ArrayList can grow and shrink dynamically as required.
An ArrayList can store multiple object types.
An ArrayList has a fixed length. (*)
31. Which of the following statements about unit testing is/are true
I. When all unit tests succeed, you can have high confidence your code is solid.
II. If a unit test fails, you donメt proceed until the code is fixed and the test succeeds.
III. Unit testing can help developer find problems early in the development cycle
I only
I and II only
II and III only (*)
I, II, and III
None of these
32. The instanceof operator enables to discover the type of object it was invoked upon.
True or false?
True (*)
False
33. A upward cast means all instance variables of the subclass are permanently lost to the
instance.
True or false?
True
False (*)
34. You can always upcast a subclass to an interface provided you don't need to access any
members of the concrete class.
True or false?
True (*)
False
36. The instanceof operator allows you to determine the type of an object.
True or false?
True (*)
False
38. Which statement added at line one allows the code to compile and run?
//line one
public class Test (
public static void main (String[] args) {
java.io.PrintWriter out = new java.io.PrintWriter
(new java.io.OutputStreamWriter (System.out), true);
System.out.println("Java");
}
}
import java.io.PrintWriter;
No statement is needed. (*)
import java.io.OutputStreamWriter
import java.io.*;
include java.io.*;
40. What is one step you must do to create your own exception?
Create a new class that implements Exception.
Create a new class that extends Exception. (*)
Declare the primitive data type Exception.
Exceptions cannot be created. They are only built in to Java.
43. Which statements are true when you compile and run this code.(Choose Two)
1. public class Test{
2. public static String sayHello(String name) throws Exception{
3. if(name == null) throw new Exception();
4. return "Hello " + name;
5. }
6. public static void main(String[] args){
7. sayHello("Java");
8. }
9. }
(Choose all correct answers)
Compilation succeeds
The class Test compiles if line 7 is enclosed in a try-catch block. try{ sayHello("Java");
}catch(Exception e){} (*)
can not create Exception object in the Test Class.
The class Test compiles if line 6 contains a throws statement. public static void main(String[]
args) throws Exception{ (*)
45. The state of an object differentiates it from other objects of the same class.
True or False?
True (*)
False
47. Modeling classes for a business problem requires understanding of the business not Java.
True or false?
True
False (*)
48. An interfaces can declare public constants.
True or False?
True (*)
False