Halaman

Tuesday, July 21, 2020

Final Exam Java Programming 2019 Learner - English

Final Exam
Section 5
(Answer all questions in this section)

Java Web Start is used to deploy Java applications.
True or false?


True (*)


False


What option do you choose from the File menu in Eclipse to start the process of creating a runnable JAR file?


Import


Properties


Switch Workspace


Export (*)



If a class is in a package, the system's CLASSPATH must be altered to access the class.
True or false?


True


False (*)



Which of the following are files that must be uploaded to a web server to deploy a Java application/applet?(Choose Three)

(Choose all correct answers)


jar files (*)


JNLP files (*)


html files (*)


.java files


None of the above



When you import a package, subpackages will not be imported.
True or false?


True (*)


False


File permissions are the same across all of the different operating systems.


True


False (*)



The Files class provides a instance method that creates a new BufferedReader.
True or false?


True (*)


False



Which of the following static methods is not provided by the Files class to check file properties or duplication?


Files.isWritable(Path p);


Files.isHidden(Path p);


Files.isArchived(Path p); (*)


Files.isReadable(Path p);



An ObjectInputStream lets you read a serialized object.
True or false?


True (*)


False



When you delete files, directories, or links with the delete(Path p) method which of the following exceptions can occur (Choose all that apply).

(Choose all correct answers)


NoSuchFileException (*)


No exception is thrown


DirectoryNotEmptyException (*)


IOException (*)


The java.nio.file package has improved exception handling.
True or false?


True (*)


False



Java 7 requires you create an instance of java.nio.file.File class.
True or false?


True


False (*)



Prior to Java 7, you write to a file with a call to the BufferedWriter class's write() method.
True or false?


True (*)


False



An absolute path always starts from the drive letter or mount point.


True (*)


False




Section 6
(Answer all questions in this section)

How many categories of JDBC drivers are there?


1


2


3


4 (*)


You must explicitly close ResultSet and Statement objects once they are no longer in use.


True (*)


False



To execute a stored SQL procedure, which JDBC interface should be used?


Statement Interface


PreparedStatement Interface


PrePreparedStatement Interface


CallableStatement Interface (*)



Given the following code, assume there are rows of data in the table EMP. What is the result?

  1 Connection conn - new Connection(URL);
  2 Statement stmt = conn.createStatement();
  3 ResultSet result - stmt.executeQuery("select count(*) from EMP");
  4 if(rs.next()){
  5 System.out.println(rs.getInt(1));
  6 }


Compiler error on line 2


Runtime error on line 3


2


0


Compiler error on line 1 (*)



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));



A


B (*)


C


The code does not compile.


A SQLException is thrown.



From JDBC, how would you execute DML statements (i.e. insert, delete, update) in the database?


By making use of the execute(...) statement from DataStatement Object


By invoking the executeDelete(...), executeUpdate(...) methods of the DataStatement


By invoking the execute(...) or executeUpdate(...) method of a JDBC Statement object or sub-interface object (*)


By invoking the DeleteStatement or UpdateStatement JDBC object


Which of the following can fill in the //INSERT HERE correctly? (Choose Two)

ResultSet rset = stmt.executeQuery(sqlQuery);
if(rs.next()){
//INSERT HERE
}


(Choose all correct answers)


Object s = rs.getObject(1); (*)


String s = rs.getString(1);


String s = rs.getObject(0);


String s = rs.getString(0);



Which of the following methods will move the cursor, returning a Boolean value from the ResultSet Object?

(Choose all correct answers)


beforeFirst() (*)


absolute()


afterFirst()


afterLast()


beforeLast()


previous() (*)



JDBC has a type system that can control the conversion between Oracle database types and Java types.


True (*)


False



Section 7
(Answer all questions in this section)

During runtime, the Java platform loads classes dynamically as required.


True (*)


False



Java allows the same Java program to be executed on multiple operating systems.


True (*)


False


Which of the following statements describe the Java programming language?


Java is a high-level programming language.


The Java programming language includes a garbage collection feature.


Java is an object oriented programming language.


All of the above (*)



Where does an object of a class get stored?


Stack area


Method area


In the file


In the database


Heap area (*)



One of the primary goals of the Java platform is to provide an interpreted, just-in-time run time environment.


True (*)


False



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.2


0.4


0.6 (*)


0.8


0.9



The function of Garbage Collection in Java is:


The JVM uses GC to clear the program output.


The JVM GC deletes all unused Java files on the system.


Memory occupied by objects with no reference is automatically reclaimed for reuse. (*)


As a Java programmer, we have to call the GC function specifically in order to manage the Java Memory.


Given the following output from the Minor GC:
[PSYoungGen: 9200K->1008K(9216K)] 9980K->3251K(19456K), 0.0045753 secs] [Times:user=0.03 sys=0.03, real=0.00 secs]
Which of the following statements is TRUE?


The pause time spent in GC is 0.03.


The size of the entire heap is 19456k (*)


This is a major garbage collection process.


The size of the tenured space is 19456k.



Which of following statements describes Parallel and Serial Garbage collection?


A Serial garbage collector uses multiple threads to manage heap space.


A Parallel garbage collector uses multiple threads to manage heap space. (*)


A Parallel garbage collector uses multiple threads to manage stack space.


A Serial garbage collector uses multiple threads to manage stack space.



Section 8
(Answer all questions in this section)

HotSpot has an HSDIS plugin to allow disassembly of code.


True (*)


False



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 line=11 means the jdb executed line 11 bytecode in the method1 method.


The bci=5 means the jdb executed the last bytecode instruction in the method1 method. (*)


The bci=5 means the jdb executed 5 lines of the source code.


From the bytecode, we can assume the Variable x is an instance variable.



The jsat tool can be used to monitor garbage collection information.


True (*)


False


Which of the following commands can be used to monitor the Java Virtual Machine statistics?


jstat (*)


javap


javac


jmap



Which of the following statements is NOT TRUE for the jdb command?


jdb can display the source code.


jdb can set the break pont for the program.


jdb can dump the stack of the current thread.


jdb can track the GC activity of the program. (*)



The attributes_count item indicates how many attributes are contained within a method.


True (*)


False



Which structure in the Java class file contains the line number information for the original source file?


method_info (*)


this_class


filed_info


cp_info



Which of the following structures are contained in a Java class file?


minor_version


major_version


access_flags


All of the above (*)


Given the following instance variable:
public void foo(){
 int i=888888;
}

Which of the following statements is NOT TRUE?


The variable i is a local variable.


The 888888 is an integer literal. After compile, the number will stay in the constant pool.


The variable i and the literal 888888 are stored in the method_info. (*)


The field descriptor for the variable i is I.



Section 9
(Answer all questions in this section)

The same class cannot be loaded by the JVM more than one time.


True (*)


False



Which of the following is NOT a java class loader?


verification class loader (*)


application class loader


bootstrap class loader


extension class loader



.class files are loaded into memory all at once, when a Java application is launched.


True


False (*)



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


In the ClassLoader hierarchy, which of the following is the only class loader that does NOT have a parent?


custom class loader


application class loader


bootstrap class loader (*)


extension class loader



opcode invokespecial is used to invoke an instance initialization method.


True (*)


False



Choose which opcode is used to push an int constant 5 onto the operand stack.


iconst_5 (*)


idc5


iload_5


iaload_5


iinc5



Choose which opcode is used to load an int from the local variable to the operand stack.


aload


iload (*)


iaload


iconst



Which of the following is NOT TRUE about Java?


The JVM offers a secure environment to run a Java application


Bytecode is not portable, and needs to be compiled again in order to run on a different platform. (*)


The JVM can interpret bytecode.


Once Java source code is compiled, it converts to bytecode.

1 comment:

  1. My.class file is located in a folder on my desktop named java burn . So, I followed the instructions and returned to my desktop command line to execute the java opennlp command.

    ReplyDelete

Final Exam Java Programming 2019 Learner - English

Final Exam