Section 3 - Data Structures: Generics and Collections
Which of the following correctly adds "Cabbage" to the ArrayList vegetables?
vegetables.add("Cabbage"); (*)
The following code is valid when working with the Collection Interface.
Collection collection = new Collection()d;
True or false?
False (*)
Which of the following would initialize a generic class "Cell" using a String type?
I. Cell cell = new Cell(); .
II. Cell cell = new Cell(); .
III. Cell cell = new String;
I and II (*)
< ? > is an example of a bounded generic wildcard.
True or False?
False (*)
The local petting zoo is writing a program to be able to collect group animals according to species to better keep track of what animals they have.
Which of the following correctly defines a collection that may create these types of groupings for each species at the zoo?
public class
animalCollection {...} (*)
A generic class is a type of class that associates one or more non-specific Java types with it.
True or False?
True (*)
Which searching algorithm involves using a low, middle, and high index value to find the location of a value in a sorted set of data (if it exists)?
Binary Search (*)
False (*)
Section 4 Strings, Recursion, Regular expressions
Square brackets are a representation for any character in regular expressions "[ ]".
False (*)
What is the correct explanation of when this code will return true?
Any time that str contains a sequence of 6 digits. (*)
Which of the following correctly defines Pattern?
Consider the following recursive method recur(x, y). What is the value of recur(4, 3)?
public static int recur(int x, int y) {
if (x == 0) {
return y;
}
return recur(x - 1, x + y);
}
13 (*)
True (*)
Which two statements can create an instance of an array? (Choose Two)
Object oa = new double[5]; (*)
Java Programing Midterm Exam
What is the output from the following code snippet?
boolean status=false;
int i=1;
if( (++i>1) && (status=true))
i++;
if( (++i>3) || (status=false))
i++;
System.out .println (i);
5 (*)
Which of the following correctly adds "Cabbage" to the ArrayList vegetables?
vegetables.add("Cabbage"); (*)
The following code is valid when working with the Collection Interface.
Collection collection = new Collection()d;
True or false?
False (*)
Which of the following would initialize a generic class "Cell" using a String type?
I. Cell cell = new Cell(); .
II. Cell cell = new Cell(); .
III. Cell cell = new String;
I and II (*)
< ? > is an example of a bounded generic wildcard.
True or False?
False (*)
The local petting zoo is writing a program to be able to collect group animals according to species to better keep track of what animals they have.
Which of the following correctly defines a collection that may create these types of groupings for each species at the zoo?
public class
animalCollection {...} (*)
A generic class is a type of class that associates one or more non-specific Java types with it.
True or False?
True (*)
Which of the following best describes lexicographical order?
An order based on the ASCII value of characters. (*)
Which of the following is the correct lexicographical order for the conents of the following int array?
{1, 1, 17, 22, 28, 29, 3, 50, 71, 83} (*)
Binary Search (*)
Why might a sequential search be inefficient?
It requires incrementing through the entire array in the worst case, which is inefficient on large data sets. (*)
Stacks are identical to Queues.
True or false?
What are maps that link a Key to a Value?
HashMaps (*)
A HashMap can only store String types.
True or false?
False (*)
A LinkedList is a type of Stack.
True or false?
True (*)
Square brackets are a representation for any character in regular expressions "[ ]".
False (*)
What is the correct explanation of when this code will return true?
Any time that str contains a sequence of 6 digits. (*)
Which of the following correctly defines Pattern?
A class in the java.util.regex package that stores the format of a regular expression. (*)
Matcher has a find method that checks if the specified pattern exists as a sub-string of the string being matched.
True (*)
Which of the following does not correctly match the regular expression symbol to its proper function?
"+" means there may be zero or more occurrences of the preceding character in the string to be a match. (*)Consider the following recursive method recur(x, y). What is the value of recur(4, 3)?
public static int recur(int x, int y) {
if (x == 0) {
return y;
}
return recur(x - 1, x + y);
}
13 (*)
A linear recursion requires the method to call which direction?
Backward (*)
A base case can handle nested conditions.
True or false?
Object oa = new double[5]; (*)
int[] ia = new int [5]; (*)
Which case handles the last recursive call?
The base case (*)
What is the result from the following code?
public class Test {
public static void main(String[] args) {
String str = "91204";
str += 23;
System.out.print(str);
}
}
9120423 (*)
What class is the split() method a member of?
String (*)
Which of the following correctly defines a StringBuilder?
A class that represents a string-like object. (*)
Which of the following correctly initializes a StringBuilder?
StringBuilder sb = new StringBuilder(); (*)
Which of the following methods are StringBuilder methods?
All of the above. (*)
What is the output from the following code snippet?
boolean status=false;
int i=1;
if( (++i>1) && (status=true))
i++;
if( (++i>3) || (status=false))
i++;
System.out .println (i);
5 (*)
The following code can be compiled, True/False?
byte b = 1 + 1;
True (*)
What is the output from the following code?
int x=0;
int y=5;
do{
++x;
y--;
}while(x<3);
System.out.println(x + " " + y);
3 2 (*)
Which statement is true when run the following statement?
1. String str = null;
2. if ((str != null) && (str.length() > 1)) {
3. System.out.println("great that number 1");
4. } else if ((str != null) & (str.length() < 2)) {
5. System.out.println("less than number 2");
6. }
The code compiles and will throw an exception at line 4. (*)
Using the code below, what will be the output if a Student object is instantiated?
The code will not compile. (*)
Examine the partial class declaration below:
class Foo{
public Foo(String s,int i ){
this(i);
}
public Foo(int i){
}
public Foo(int i,int j){
}
}
Which of following statements can not be used to create a instance of Foo?
Foo f=new Foo(); (*)
7. Examine the following Classes:
Student and TestStudent
What is the output from the println statement in TestStudent?
public class Student {
private int studentId = 0;
public Student(){
studentId++;
}
public static int getStudentId(){
return studentId;
}
}
public class TestStudent {
public static void main(String[] args) {
Student s1 = new Student();
Student s2 = new Student();
Student s3 = new Student();
System.out.println(Student.getStudentId());
}
}
No output. Compilation of TestStudent fails (*)
What is the output from the following code snippet?
class Shape{
public void paint(){System.out.print("Shape");}
class Circle extends Shape{
public void paint() throws Exception{
System.out.print("Circle ");
throw new Exception();
}
public static void main(String[] args){
try{new Circle().paint();}
catch(Exception e){System.out.println("Exception");
}
}
Exception (*)
What is the definition of a logic error?
Bugs in code that make your program run different than expected (*)
When do you use try-catch statements?
When you want to handle an exception. (*)
Assertions are boolean statements to test and debug your programs.
True or false?
True (*)
Which of the following statements about inheritance is false?
Through inheritance, a parent class is a more specialized form of the child class. (*)
When an object is able to pass on its state and behaviors to its children, this is called:
Inheritance (*)
Examine the following code snippet. What is this an example of?
Inheritance (*)
Modeling business problems requires understanding the interaction between interfaces, abstract and concrete classes, subclasses, and enum classes.
True (*)
In general, classes can be made immutable by placing a final key word before the class keyword.
True or false?
True (*)
Which two statements are equivalent to line 2?
(Choose Two)
1. public interface Account{
2. int accountID=100;
3. }
Final int accountID=100; (*)
static int accountID=100; (*)
When line 10 is executed, which method will be called?
1 class Account {
2 public void deposit(int amt, int amt1) { }
3 public void deposit(int amt){ }
4 }
5 public class CreditAccount extends Account {
6 public void deposit() { }
7 public void deposit(int amt) {}
8 public static void main(String args[]){
9 Account account = new CreditAccount();
10 account.deposit(10);
11 }
12 }
line 7 (*)
Which one of the following would allow you to define the abstract class Animal.
public abstract class Animal{} (*)
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 (*)
Which scenario best describes a queue?
A line at the grocery store where the first person in the line is the first person to leave. (*)
The Comparable interface defines the compareTo method.
True or false?
True (*)
Nodes are components of LinkedLists, and they identify where the next and previous nodes are.
True or false?
True (*)
A LinkedList is a type of Stack.
True or false?
True (*)
Implementing the Comparable interface in your class allows you to define its sort order.
True or false?
True (*)
Big-O Notation is used in Computer Science to describe the performance of Sorts and Searches on arrays. True or false?
True (*)
Bubble Sort is a sorting algorithm that involves swapping the smallest value into the first index, finding the next smallest value and swapping it into the next index and so on until the array is sorted.
True or false?
False (*)
A sequential search is an iteration through the array that stops at the index where the desired element is found. True or false?
True (*)
Why might a sequential search be inefficient?
It requires incrementing through the entire array in the worst case, which is inefficient on large data sets. (*)
Which searching algorithm involves using a low, middle, and high index value to find the location of a value in a sorted set of data (if it exists)?
Binary Search (*)
Choose the best definiton for a collection.
It is an interface in the java.util package that is used to define a group of objects. (*)
Sets may contain duplicates.
True or false?
False (*)
What is a set?
A collection of elements that does not contain duplicates. (*)
A HashSet is a set that is similar to an ArrayList. A HashSet does not have any specific ordering
True (*)
public static void printArray(T[] array){....
is an example of what?
A generic method (*)
A generic class increases the risk of runtime class conversion exceptions.
True or False?
False (*)
What is the correct definition of Enumeration (or enum)?
A keyword that specifies a class whose objects are defined inside the class. (*)
Wildcards in generics allows us greater control on the types that can be used.
True or False?
True (*)
he local petting zoo is writing a program to be able to collect group animals according to species to better keep track of what animals they have.
Which of the following correctly defines a collection that may create these types of groupings for each species at the zoo?
public class
animalCollection {...} (*)
The base case condition can work with a constant or variable.
True or false?
True (*)
Which two statements can create an instance of an array? (Choose Two)
int[] ia = new int [5]; (*)
Object oa = new double[5]; (*)
A linear recursion requires the method to call which direction?
Backward (*)
A non-linear recursive method is less expensive than a linear recursive method.
True or false?
False (*)
The following code correctly initializes a pattern with the regular expression "[0-9]{2}/[0-9]{2}/[0-9]{2}".
Pattern dateP = Pattern.compile("[0-9]{2}/[0-9]{2}/[0-9]{2}");
True or false?
True (*)
A regular expression is a character or a sequence of characters that represent a string or multiple strings.
True or false?
True (*)
Which of the following does not correctly match the regular expression symbol to its proper function?
+" means there may be zero or more occurrences of the preceding character in the string to be a match. (*)
Consider designing a program that organizes your contacts alphabetically by last name, then by first name. Oddly, all of your contacts' first and last names are exactly five letters long.
Which of the following segments of code establishes a Pattern namePattern with a group for the first name and a group for the last name considering that the string contactsName is always in the format lastName_firstName?
Pattern namePattern = Pattern.compile("(.{5})_(.{5})"); (*)
Which of the following methods can be used to replace a segment in a string with a new string?
replaceAll(String oldString, String newString) (*)
Which of the following correctly defines a StringBuilder?
A class that represents a string-like object. (*)
Which of the following methods are StringBuilder methods?
All of the above. (*)
Section 5 Input And Output
The System.in is what type of stream?
An InputStream (*)
The Files class provides a instance method that creates a new BufferedReader.
True or false?
True (*)
You can read input by character or line.
True or false?
True (*)
When you delete files, directories, or links with the delete(Path p) method which of the following exceptions can occur (Choose all that apply).
DirectoryNotEmptyException (*)
NoSuchFileException (*)
Section 7 Java Memory and the JVM
During runtime, the Java platform loads classes dynamically as required.
True (*)
Given the java snippet below:
public class Foo{
int x;
public void testFoo(){
int y=100;
}
}
Which of the following statements is TRUE?
Variable x resides in the heap area, and variable y resides in the stack of the JVM (*)
Given the following declaration of the method test:
public static void test(String s, int i);
The forName() method does not initialize the HelloClass. (*)
The forName() method does not load the HelloClas class into the Java Runtime. (*)
The forName method will instantiate a HelloClass object. (*)
The System or Application ClassLoader loads Java classes from the System Classpath. This classpath is set by the CLASSPATH environment variable.
False (*)
Final exam:
The java.io package has problems with no support for symbolic links. True or false?
True (*)
The System.in is what type of stream?
An InputStream (*)
The Files class provides a instance method that creates a new BufferedReader.
True or false?
True (*)
You can read input by character or line.
True or false?
True (*)
When you delete files, directories, or links with the delete(Path p) method which of the following exceptions can occur (Choose all that apply).
DirectoryNotEmptyException (*)
NoSuchFileException (*)
The read() method of java.io.Reader class lets you read a character at a time.
True or false?
True (*)
An example of two tier architecture would be a client application working with a server application.
True or false?
True (*)
To deploy java applications you may use Java Web Start.
True or false?
True (*)
When you import a package, subpackages will not be imported.
True or false?
True (*)
Which of the following is not a reason to use a Java package?
It is a way to allow programmers to receive packets of information from databases. (*)
The import keyword allows you to access classes of the package without package Fully Qualified Name. True or false?
True (*)
The java.io package has problems with no support for symbolic links.True or false?
True (*)
An absolute path always starts from the drive letter or mount point.
True (*)
The new Paths class lets you resolve .. (double dot) path notation. True or false?
True (*)
The way that you read from a file has changed since the introduction of Java 7.
True or false?
True (*)
Prior to Java 7, you write to a file with a call to the BufferedWriter class's write() method.
True or false?
True (*)
6 - JDBC
Which of the following is a valid JDBC URL?
Which of the following is a valid JDBC URL?
jdbc:oracle:thin:dfot/dfot@localhost:1521/xepdb1 (*)
What type of JDBC driver will convert the database invocation directly into network protocol?
Type 4 driver (*)
Which of the following is NOT a JDBC interface used to execute SLQ statements?
PrePreparedStatement Interface (*)
Given the following code, assume there are rows of data in the table EMP. What is the result?
3 ResultSet result - stmt.executeQuery("select count(*) from EMP");
You must explicitly close ResultSet and Statement objects once they are no longer in use.
True (*)
Which of the following is the correct order to close the database object?
ResultSet, Statement, Connection (*)
Which of the following classes or interfaces are included in the database vendor driver library? (Choose two)
Statement interface implementation (*)
Javax.sql.DataSource implementation (*)
Which of the following methods will move the cursor, returning a Boolean value from the ResultSet Object?
beforeFirst() (*)
previous() (*)
JDBC has a type system that can control the conversion between Oracle database types and Java types.
True (*)
Suppose that you have a table EMPLOYEES with three rows. The first_name in those rows are A, B, and C. What does the following output?
String sql = "select first_name from Employees order by first_name desc";
Statement stmt=conn.createStatement = (ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);
ResultSet rset= stmt.executeQuery(sql);
rset.absolute(1);
rset.next();
System.out.println(rset.getString(1));
B (*)
Which JDBC interface can be used to access information such as database URL, username and table names?
DatabaseMetaData Interface (*)
Which symbol is used as a placeholder to pass parameters to a PreparedStatement or CallableStatement?
? (*)
Which of the following is the correct statement be inserted at //INSERT CODE location that calls the database-stored procedure sayHello?
Which of the following is the correct statement be inserted at //INSERT CODE location that calls the database-stored procedure sayHello?
class Test{
public static void main(String[] args) {
try {
Connection conn = getConnection();
//INSERT CODE
cstat.setString(1, "Hello");
cstat.registerOutParameter(2, Types.NUMERIC);
cstat.setInt(2, 10);
}
catch(SQLException e){}
}
}
CallableStatement cstat = con.prepareCall("{call sayHello(?, ?)}"); (*)
Which of the following can fill in the //INSERT HERE correctly? (Choose Two)
ResultSet rset = stmt.executeQuery(sqlQuery);
if(rs.next()){
//INSERT HERE
}
Mark for Review
(1) Points
(Choose all correct answers)
Object s = rs.getObject(1); (*)
From JDBC, how would you execute DML statements (i.e. insert, delete, update) in the database?
By invoking the execute(...) or executeUpdate(...) method of a JDBC Statement object or sub-interface object (*)
During runtime, the Java platform loads classes dynamically as required.
True (*)
Where does an object of a class get stored?
Heap area (*)
public class Foo{
int x;
public void testFoo(){
int y=100;
}
}
Which of the following statements is TRUE?
Variable x resides in the heap area, and variable y resides in the stack of the JVM (*)
Which of the following statements is NOT true of the Java programming language?
The javac command can be used to run a Java application. (*)
One of the primary goals of the Java platform is to provide an interpreted, just-in-time run time environment.
True (*)
Which of the following statements is NOT TRUE about the JVM?
The JVM reads Java source code, and then translates it into byte code. (*)
Java allows the same Java program to be executed on multiple operating systems.
True (*)
Which of the following statements describe the Java programming language?
All of the above (*)
The function of Garbage Collection in Java is:
Memory occupied by objects with no reference is automatically reclaimed for reuse. (*)
In which area of heap memory are newly created objects stored
Eden (*)
Which of the following statements is NOT TRUE for the JVM heap?
Java Developer can explicitly allocate and deallocate the Heap Memory. (*)
Which of the following allows the programmer to destroy an object referenced by x?
Only the garbage collection system can destroy an object. (*)
Which of following statements describes Parallel and Serial Garbage collection?
A Parallel garbage collector uses multiple threads to manage heap space. (*)
Given the following code snippet:
String str = new String("Hello");
The "Hello" String literal will be located in which memory area in the JVM during runtime?
In the constant pool area of the run-time data area in the JVM. (*)
Given the following output from the Minor GC:
[GC [DefNew: 4032K->64K(4032K), 0.0429742 secs] 9350K->7748K(32704K), 0.0431096 secs]
Which of the following statements is TRUE?
Entire heap is 9350k.
Section 8 - class File and The JDK
Given the following declaration of the method test:
public static void test(String s, int i);
(Ljava/lang/String;I)V (*)
Given the following class structure:
public class Shape{
void foo(){}
}
public class Circle extends Shape{
void draw(){}
}
Which of the following statements is TRUE?
The foo method definition is only contained in the Shape class. (*)
Which of the following structures are contained in a Java class file?
minor_version
major_version
access_flags
All of the above (*)
In a valid Java class file, the magic number is always:
CAFEBABE (*)
Which structure in the Java class file contains the line number information for the original source file?
method_info (*)
Given the following instance variable:
public void foo(){
int i=888888;
}
Which of the following statements is NOT TRUE?
The variable i and the literal 888888 are stored in the method_info. (*)
The javac command can be used to display native code in Java
False (*)
Before we can use the jsat tool we first have to use the jps tool to obtain JVM process id numbers.
True (*)
Which of the following commands allows a developer to see the effects of a running java application on memory and CPU?
jvisualvm (*)
HotSpot has an HSDIS plugin to allow disassembly of code.
True (*)
The jsat tool can be used to monitor garbage collection information.
True (*)
Which of the following commands can be used to translate Java source code into bytecode?
javac (*)
Which of the following statements is NOT TRUE for the jdb command?
jdb can track the GC activity of the program. (*)
Given the following information in the jdb tool, jdb paused at line 11:
9 public static void method1(){
10 x=100;
11 }
public static void method1();
Code:
0: bipush 100
2: putstatic #7 //Field x:I
5: return
Which statement is true?
Step completed: "thread-main", Example.method1(), line=11 bci=5
The bci=5 means the jdb executed the last bytecode instruction in the method1 method. (*)
Which of the following commands is used to launch a java program?
java (*)
9. ByteCode and Classes
Which of the following is NOT a java class loader?
Which of the following is NOT a java class loader?
verification class loader (*)
.class files are loaded into memory all at once, when a Java application is launched.
False (*)
The Java developer can define a number of additional or custom classloaders.
True (*)
Which of the following from ClassLoader will load the rt.jar, the Java core clsses which are present in the java.* package?
Bootstrap Class Loader (*)
In the ClassLoader hierarchy, which of the following is the only class loader that does NOT have a parent?
bootstrap class loader (*)
Which of the following exceptions is thrown by the loadClass() method of ClassLoader class?
ClassNotFoundException (*)
ClassNotFoundException (*)
Which of the following statements is NOT TRUE for the Class.forName("HelloClass") method? (Choose three)
The forName() method does not initialize the HelloClass. (*)
The forName() method does not load the HelloClas class into the Java Runtime. (*)
The forName method will instantiate a HelloClass object. (*)
The System or Application ClassLoader loads Java classes from the System Classpath. This classpath is set by the CLASSPATH environment variable.
False (*)
The same class cannot be loaded by the JVM more than one time.
True (*)
True (*)
Bytecode is an intermediate representation of a program, somewhere between source code and machine code.
True (*)
Choose which opcode is used to fetch a field from object.
getfield (*)
Which of the following is NOT TRUE about Java?
Bytecode is not portable, and needs to be compiled again in order to run on a different platform. (*)
Bytecode contains different opcodes for every type of loop written in source code
False (*)
Choose which opcode is used to push an int constant 5 onto the operand stack.
iconst_5 (*)
Choose which opcode is used to load an int from the local variable to the operand stack.
iload (*)
Final exam:
The java.io package has problems with no support for symbolic links. True or false?
True (*)
The new Paths class lets you resolve .. (double dot) path notation.
True or false?
True (*)
An absolute path always starts from the drive letter or mount point.
True (*)
Java 7 requires you create an instance of java.nio.file.File class.
True or false?
False (*)
A jar file is built on the ZIP file format and is used to deploy java applets.
True (*)
When you import a package, subpackages will not be imported.
True or false?
True (*)
An example of two tier architecture would be a client application working with a server application.
True (*)
To deploy java applications you may use Java Web Start.
True or false?
True (*)
Which of the following is an attribute of a three tier architecture application?
a complex application that includes a client, a server and database (*)
Which of the following static methods is not provided by the Files class to check file properties or duplication?
Files.isArchived(Path p); (*)
You can read input by character or line.
True or false?
True (*)
The BufferedInputStream is a direct subclass of what other class?
FilterInputStream (*)
The Files class provides a instance method that creates a new BufferedReader.
True (*)
The System.out is what type of stream?
A PrintStream (*)
How many categories of JDBC drivers are there?
4 (*)
The java.sql.DriverManager class will typically be registered with a naming service based on the Java Naming Directory (JNDI) API
False (*)
Which of the following classes or interfaces are included in the database vendor driver library? (Choose two)
Statement interface implementation (*)
Javax.sql.DataSource implementation (*)
What type of JDBC driver will convert the database invocation directly into network protocol?
Type 4 driver (*)
JDBC has a type system that can control the conversion between Oracle database types and Java types.
True (*)
Which of the following can fill in the //INSERT HERE correctly? (Choose Two)
ResultSet rset = stmt.executeQuery(sqlQuery);
if(rs.next()){
//INSERT HERE
}
Object s = rs.getObject(1); (*)
Which of the following methods will move the cursor, returning a Boolean value from the ResultSet Object?
previous() (*)
Which the following statements is NOT TRUE about DataSource?
DataSource can manage a set of JDBC Drivers registered in the system. (*)
Which of the following is the correct statement be inserted at //INSERT CODE location that calls the database-stored procedure sayHello?
class Test{
public static void main(String[] args) {
try {
Connection conn = getConnection();
//INSERT CODE
cstat.setString(1, "Hello");
cstat.registerOutParameter(2, Types.NUMERIC);
cstat.setInt(2, 10);
}
catch(SQLException e){}
}
}
CallableStatement cstat = con.prepareCall("{call sayHello(?, ?)}"); (*)
Which of the following statements is NOT TRUE about the JVM?
The JVM reads Java source code, and then translates it into byte code. (*)
Java allows the same Java program to be executed on multiple operating systems.
True (*)
Which of the following statements is NOT true of the Java programming language?
The javac command can be used to run a Java application. (*)
One of the primary goals of the Java platform is to provide an interpreted, just-in-time run time environment.
True (*)
Where does an object of a class get stored?
Heap area (*)
Which of the following statements is NOT TRUE for the JVM heap?
Java Developer can explicitly allocate and deallocate the Heap Memory. (*)
Which of following statements describes Parallel and Serial Garbage collection?
A Parallel garbage collector uses multiple threads to manage heap space. (*)
Given the following output from the Minor GC:
[GC [DefNew: 4032K->64K(4032K), 0.0429742 secs] 9350K->7748K(32704K), 0.0431096 secs]
What estimated percentage of the Java objects will be promoted from Young space to Tenured space?
0.6 (*)
Given the following code snippet:
String str = new String("Hello");
The "Hello" String literal will be located in which memory area in the JVM during runtime?
In the constant pool area of the run-time data area in the JVM. (*)
The class file contains the definition it inherits from the superclass.
False (*)
In a valid Java class file, the magic number is always:
CAFEBABE (*)
The attributes_count item indicates how many attributes are contained within a method.
True (*)
Which of the following structures are contained in a Java class file?
minor_version
major_version
access_flags
All of the above (*)
Which of the following commands can be used to translate Java source code into bytecode?
javac (*)
Which of the following statements is NOT TRUE for the jdb command?
jdb can track the GC activity of the program. (*)
HotSpot has an HSDIS plugin to allow disassembly of code.
True (*)
Given the following information in the jdb tool, jdb paused at line 11:
9 public static void method1(){
10 x=100;
11 }
public static void method1();
Code:
0: bipush 100
2: putstatic #7 //Field x:I
5: return
Which statement is true?
Step completed: "thread-main", Example.method1(), line=11 bci=5
The bci=5 means the jdb executed the last bytecode instruction in the method1 method. (*)
Which of the following commands can be used to monitor the Java Virtual Machine statistics?
jstat (*)
The same class cannot be loaded by the JVM more than one time.
True (*)
The process of linking involves which of the following processes?
verification
preparation
resolution
All of the above (*)
Which of the following exceptions is thrown by the loadClass() method of ClassLoader class?
ClassNotFoundException (*)
The Java developer can define a number of additional or custom classloaders.
True (*)
Which of the following is NOT a java class loader?
verification class loader (*)
Bytecode contains different opcodes for every type of loop written in source code.
False (*)
Bytecode is an intermediate representation of a program, somewhere between source code and machine code.
True (*)
Which of the following opcode instructions would add 2 integer variables?
iadd (*)
opcode invokespecial is used to invoke an instance initialization method.
True (*)