Академический Документы
Профессиональный Документы
Культура Документы
java programming
Section 1
(Answer all questions in this section)
10. The function of Garbage Collection in Java is: Mark for Review BLOG ARCHIVE
(1) Points ▼ 2018 (1)
▼ October (1)
karre jawa oracle java programming
The JVM uses GC to clear the program output. midterm and sec...
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.
1. Which of the following statements is NOT true of the Java programming language? Mark for
Review
(1) Points
All source code is written in plain text files with the extension .java.
Java source code files are compiled into .class files by the javac command.
Correct Correct
2. Which of the following statements describe the Java programming language? Mark for
Review
(1) Points
Correct Correct
3. Given the java snippet below:
Variable x resides in the stack area, and variable y resides in the heap of the JVM.
Variable x resides in the heap area, and variable y resides in the stack of the JVM (*)
Variable x stays in the heap area, and variable y resides in the method area of the JVM.
Correct Correct
4. Which of the following converts a human-readable file into a platform-independent code file
in Java? Mark for Review
(1) Points
JRE
JDK
java command
5. Java allows the same Java program to be executed on multiple operating systems. Mark for
Review
(1) Points
True (*)
False
Correct Correct
6. Which of the following statements describe Java technology? Mark for Review
(1) Points
It is a programming language.
It is a development environment.
It is a deployment environment.
7. During runtime, the Java platform loads classes dynamically as required. Mark for Review
(1) Points
True (*)
False
Correct Correct
8. One of the primary goals of the Java platform is to provide an interpreted, just-in-time run
time environment. Mark for Review
(1) Points
True (*)
False
In the constant pool area of the run-time data area in the JVM. (*)
str will stay in the heap area of the run-time data area in the JVM.
str will stay in the method area of the run-time data area in the JVM.
str will stay in the stack area of the run-time data area in the JVM. (*)
str will stay in the heap area of the constant pool run-time data area in the JVM.
12. In which area of heap memory are newly created objects stored? Mark for Review
(1) Points
Survivor Space 0
Survivor Space 1
Eden (*)
Tenured
13. Which of the following allows the programmer to destroy an object referenced by x? Mark
for Review
(1) Points
x.remove();
x.finalize();
x.delete();
Correct Correct
14. Which of following statements describes Parallel and Serial Garbage collection? Mark for
Review
(1) Points
A Parallel garbage collector uses multiple threads to manage heap space. (*)
15. Which of the following statements is NOT TRUE for the JVM heap? Mark for Review
(1) Points
Java Developer can explicitly allocate and deallocate the Heap Memory. (*)
Correct Correct
1. Given the java snippet below:
Variable x resides in the stack area, and variable y resides in the heap of the JVM.
Variable x resides in the heap area, and variable y resides in the stack of the JVM (*)
Variable x stays in the heap area, and variable y resides in the method area of the JVM.
Correct Correct
2. Which of the following statements describe the Java programming language? Mark for
Review
(1) Points
Java is a high-level programming language.
Correct Correct
3. During runtime, the Java platform loads classes dynamically as required. Mark for Review
(1) Points
True (*)
False
Correct Correct
4. Which of the following statements is NOT TRUE about the JVM? Mark for Review
(1) Points
The JVM is a virtual Machine that acts as an intermediary layer between the Java Application
and the Native Operating System.
The JVM reads byte code from the class file, and generates machine code.
The JVM reads Java source code, and then translates it into byte code. (*)
Stack area
Method area
In the file
In the database
True (*)
False
Correct Correct
7. Which of the following converts a human-readable file into a platform-independent code file
in Java? Mark for Review
(1) Points
JRE
JDK
java command
Correct Correct
8. One of the primary goals of the Java platform is to provide an interpreted, just-in-time run
time environment. Mark for Review
(1) Points
True (*)
False
Correct Correct
9. Which of following statements describes Parallel and Serial Garbage collection? Mark for
Review
(1) Points
A Parallel garbage collector uses multiple threads to manage heap space. (*)
Correct Correct
Correct Correct
11. Which of the following statements is NOT TRUE for the JVM heap? Mark for Review
(1) Points
Java Developer can explicitly allocate and deallocate the Heap Memory. (*)
Correct Correct
In the constant pool area of the run-time data area in the JVM. (*)
0.2
0.4
0.6 (*)
0.8
0.9
14. Which of the following allows the programmer to destroy an object referenced by x? Mark
for Review
(1) Points
x.remove();
x.finalize();
x.delete();
Correct Correct
str will stay in the heap area of the run-time data area in the JVM.
str will stay in the method area of the run-time data area in the JVM.
str will stay in the stack area of the run-time data area in the JVM. (*)
str will stay in the heap area of the constant pool run-time data area in the JVM.
Correct Correct
Section 2
(Answer all questions in this section)
1. Which of the following commands allows a developer to see the effects of a running java
application on memory and CPU? Mark for Review
(1) Points
javac
jvisualvm (*)
java
javap
Correct Correct
2. HotSpot has an HSDIS plugin to allow disassembly of code. Mark for Review
(1) Points
True (*)
False
Correct Correct
3. Which of the following commands is used to launch a java program? Mark for Review
(1) Points
javac
jvisualvm
java (*)
javap
4. Before we can use the jsat tool we first have to use the jps tool to obtain JVM process id
numbers. Mark for Review
(1) Points
True (*)
False
Correct Correct
5. Given the following information in the jdb tool, jdb paused at line 11:
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.
Correct Correct
6. The javac command can be used to display native code in Java Mark for Review
(1) Points
True
False (*)
7. The jsat tool can be used to monitor garbage collection information. Mark for Review
(1) Points
True (*)
False
3. Which of the following structures are contained in a Java class file? Mark for Review
(1) Points
minor_version
major_version
access_flags
magic
access_flags
method_info (*)
major_version
Which structure in the Java class file contains the line number information for the original
source file? Mark for Review
(1) Points
method_info (*)
this_class
filed_info
cp_info
Which of the following commands can be used to translate Java source code into bytecode?
Mark for Review
(1) Points
java
javac (*)
jdb
jstat
Correct Correct
8. Which of the following commands can be used to monitor the Java Virtual Machine
statistics? Mark for Review
(1) Points
jstat (*)
javap
javac
jmap
9. Which of the following statements is NOT TRUE for the jdb command? Mark for Review
(1) Points
10. The class file contains the definition it inherits from the superclass. Mark for Review
(1) Points
True
False (*)
Incorrect Incorrect. Refer to Section 2 Lesson 2.
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. (*)
Correct Correct
12. The attributes_count item indicates how many attributes are contained within a method.
Mark for Review
(1) Points
True (*)
False
10. Like in the Java source code file, one Java class file can contain multiple class definitions.
Mark for Review
(1) Points
True
False (*)
Correct Correct
Which of the following is the descriptor of the test method in the class file? Mark for Review
(1) Points
(java/lang/String;int)V
(Ljava/lang/String;I)V (*)
V(Ljava/lang/String;I)
(Ljava/lang/String;java.lang.Integer)V
The Circle class contains both the foo and draw method definitions.
The foo method definition is only contained in the Shape class. (*)
If a Circle object is instantiated, the constructor of Circle will call the constructor of Shape.
15. In a valid Java class file, the magic number is always: Mark for Review
(1) Points
42
CAFEBABE (*)
1.618
BABECAFE
1. opcode invokespecial is used to invoke an instance initialization method. Mark for Review
(1) Points
True (*)
False
Correct Correct
True (*)
False
Correct Correct
3. To inspect bytecode, which option is used with the javap command to disassemble the class
file? Mark for Review
(1) Points
-a
-b
-c (*)
-d
4. Choose which opcode is used to load an int from the local variable to the operand stack.
Mark for Review
(1) Points
aload
iload (*)
iaload
iconst
True (*)
False
Correct Correct
6. Choose which opcode is used to push an int constant 5 onto the operand stack. Mark for
Review
(1) Points
iconst_5 (*)
idc5
iload_5
iaload_5
iinc5
7. .class files are loaded into memory all at once, when a Java application is launched. Mark
for Review
(1) Points
True
False (*)
8. The Java developer can define a number of additional or custom classloaders. Mark for
Review
(1) Points
True (*)
False
Correct Correct
The forName() method returns the Class object associated with the HelloClass.
The forName() method does not load the HelloClas class into the Java Runtime. (*)
In this example, the Class.forName("HelloClass") will use the ClassLoader which loads the Foo
class.
10. The process of linking involves which of the following processes? Mark for Review
(1) Points
verification
preparation
resolution
11. In the ClassLoader hierarchy, which of the following is the only class loader that does NOT
have a parent? Mark for Review
(1) Points
12. Which of the following exceptions is thrown by the loadClass() method of ClassLoader
class? Mark for Review
(1) Points
IOException
SystemException
ClassFormatError
ClassNotFoundException (*)
13. The same class cannot be loaded by the JVM more than one time. Mark for Review
(1) Points
True (*)
False
Correct Correct
14. Which of the following from ClassLoader will load the rt.jar, the Java core clsses which are
present in the java.* package? Mark for Review
(1) Points
15. The System or Application ClassLoader loads Java classes from the System Classpath.
This classpath is set by the CLASSPATH environment variable. Mark for Review
(1) Points
True
False (*)
Section 4
(Answer all questions in this section)
a,b
ac
a,b,c (*)
abc
Correct Correct
Which of following arguments can be passed into the method? (Choose Two) Mark for Review
(1) Points
3. Which three are valid declarations for a float value? (Choose Three) Mark for Review
(1) Points
float f = 3.0L;
float f = 1.0;
4. Which two statements prevent a method from being overriden? (Choose Two) Mark for
Review
(1) Points
6. Which of the following operators are relational operators?(Choose Two) Mark for Review
(1) Points
"+="
"!=" (*)
">=" (*)
"="
7. Which of the following operators are logic operators?(Choose Two) Mark for Review
(1) Points
&& (*)
<=
>
! (*)
2. Which statement is a syntactically correct way to declare an Array? Mark for Review
(1) Points
int i[1];
int[5] id={1,2,3,4,5};
12
Correct Correct
4. What is the final value of result from the following code snippet?
int i = 1;
int [] id = new int [3];
int result = id [i];
result = result + i; Mark for Review
(1) Points
An exception is thrown.
Correct Correct
i=0123456789
i=012 (*)
i=0123
i=012456789
public Student(){
studentId++;
}
public static int getStudentId(){
return studentId;
}
}
7. Which of following relationships does not use inheritance? Mark for Review
(1) Points
Correct Correct
You can use access modifiers to control which other classes can call the constructor. (*)
You can declare more than one constructor in a class declaration. (*)
int i=0,j=0;
i=++i;
j=i++;
System.out.println("i=" + i + " " + "j=" + j); Mark for Review
(1) Points
10. Which two statements best describe data encapsulation? (Choose Two) Mark for Review
(1) Points
22
3 2 (*)
23
33
True
False (*)
int[] myarray={1,2,3,4,5};
int sum=0;
for (int x : myarray)
sum+=x;
System.out.println("sum= " + sum); Mark for Review
(1) Points
10
20
15 (*)
14. Which of following statments are true when you create a object from class Object at
runtime as seen below. (Choose Three)
This Object instance will not be created because you never defined class Object.
1. Which of following relationships does not use inheritance? Mark for Review
(1) Points
Correct Correct
3 2 (*)
33
23
22
When no constructor is defined in the class, the compiler will create a default constructor.
Correct Correct
5. A class can be extended by more than one class. True or False? Mark for Review
(1) Points
True (*)
False
Correct Correct
int i=0,j=0;
i=++i;
j=i++;
System.out.println("i=" + i + " " + "j=" + j); Mark for Review
(1) Points
8. Which combination of the following overload the Student constructor?(Choose Two) Mark
for Review
(1) Points
9. Which two statements are access modifier keywords in Java?(Choose Two) Mark for
Review
(1) Points
abstract
final
protected (*)
public (*)
11. When you instantiate a subclass, the superclass constructor will be also invoked. True or
False? Mark for Review
(1) Points
True (*)
False
Correct Correct
You can use access modifiers to control which other classes can call the constructor. (*)
Since a constructor can not return any value, it should be declared as void.
You can declare more than one constructor in a class declaration. (*)
Correct Correct
13. Which ofthe following declarations are wrong?(Choose Three) Mark for Review
(1) Points
Correct Correct
int x = 1;
int y;
while(++x < 5)
y++;
System.out.println(y); Mark for Review
(1) Points
Section 5
(Answer all questions in this section)
True
False (*)
True
False (*)
True
False (*)
4. Unit testing can help you isolate problem quickly. True or False? Mark for Review
(1) Points
True (*)
False
Correct Correct
5. The main purpose of unit testing is to verify that an individual unit (a class, in Java) is
working correctly before it is combined with other components in the system. True or false?
Mark for Review
(1) Points
True (*)
False
7. Which of the following is the correct way to throw cumstom ServerException? Mark for
Review
(1) Points
throw ServerException
throws ServerException
raise ServerException
Correct Correct
8. What symbol(s) is used to separate multiple exceptions in one catch statement? Mark for
Review
(1) Points
&&
(==) (equals equals)
class Shape{
public void paint(){System.out.print("Shape");}
Circle
Shape
ShapeCircle
Exception
10. Assertions are boolean statements to test and debug your programs.
True or false? Mark for Review
(1) Points
True (*)
False
Correct Correct
11. Which three types of objects can be thrown using a throw statement? (Choose Three) Mark
for Review
(1) Points
Error (*)
Event
Exception (*)
Throwable (*)
Object
12. The instanceof operator can find subclass objects when they are passed to method which
declare a superclass type parameter.
True or false? Mark for Review
(1) Points
True (*)
False
Correct Correct
13. The instanceof operator allows you to determine the type of an object.
True or false? Mark for Review
(1) Points
True (*)
False
Correct Correct
14. Which one of the following would allow you to define the abstract class Animal. Mark for
Review
(1) Points
public Animal{}
True (*)
False
1. Immutable classes can be subclassed.
True or false? Mark for Review
(1) Points
True
False (*)
Correct Correct
2. Which one of the following would allow you to define an interface for Animal? Mark for
Review
(1) Points
True
False (*)
Correct Correct
4. The instanceof operator can find subclass objects when they are passed to method which
declare a superclass type parameter.
True or false? Mark for Review
(1) Points
True (*)
False
Correct Correct
5. Which method will force a subclass to implement it? Mark for Review
(1) Points
Correct Correct
Section 5
(Answer all questions in this section)
I only
II only
None of these
2. Reading great code is just as important for a programmer as reading great books is for a
writer. True or false? Mark for Review
(1) Points
True (*)
False
Correct Correct
3. Unit testing can help you isolate problem quickly. True or False? Mark for Review
(1) Points
True (*)
False
Correct Correct
4. What is the result from creating the following try-catch block?
1.try {
5. What is one step you must do to create your own exception? Mark for Review
(1) Points
Correct Correct
. 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");
}
} Mark for Review
(1) Points
import java.io.OutputStreamWriter
include java.io.*;
import java.io.PrintWriter;
import java.io.*;
Incorrect Incorrect. Refer to Section 5 Lesson 3.
True
False (*)
9. Virtual method invocation requires that the superclass method is defined as which of the
following? Mark for Review
(1) Points
True (*)
False
Correct Correct
11. Which line contains an compilation error?
interface Shape {}
interface InnerShape extends Shape{}
class Circle implements Shape{ }
class InnerCircle extends Circle{}
class Rectangle implements Shape{}
public class Tester {
public static void main(String[] args) {
Line 2
Line 3 (*)
Line 4
Line 1
Correct Correct
True
False (*)
13. In general, classes can be made immutable by placing a final key word before the class
keyword.
True or false? Mark for Review
(1) Points
False
True (*)
Correct Correct
14. The state of an object differentiates it from other objects of the same class.
True or False? Mark for Review
(1) Points
True (*)
False
Correct Correct
15. Which one of the following would allow you to define an interface for Animal? Mark for
Review
(1) Points
Correct Correct
ection 5
(Answer all questions in this section)
Correct Correct
2. Which statements are true when you compile and run this code.(Choose Two)
The class Test compiles if line 6 contains a throws statement. public static void main(String[]
args) throws Exception{ (*)
The class Test compiles if line 7 is enclosed in a try-catch block. try{ sayHello("Java");
}catch(Exception e){} (*)
Compilation succeeds
True (*)
False
Correct Correct
True (*)
False
NullPointerException
Java
Exception
True
False (*)
7. The instanceof operator can find subclass objects when they are passed to method which
declare a superclass type parameter.
True or false? Mark for Review
(1) Points
True (*)
False
Correct Correct
True (*)
False
Correct Correct
9. You can't downcast an object explicitly because you must use virtual method invocation.
True or false? Mark for Review
(1) Points
True
False (*)
10. Unit testing can help you isolate problem quickly. True or False? Mark for Review
(1) Points
True (*)
False
Correct Correct
11. Which of the following statements about arrays and ArrayLists in Java are true?
I. An Array has a fixed length.
II. An Array can grow and shrink dynamically as required.
III. An ArrayList can store multiple object types.
IV. In an ArrayList you need to know the length and the current number of elements stored.
Mark for Review
(1) Points
II and IV only
None of these
12. Which statement is true for the class java.util.ArrayList? Mark for Review
(1) Points
True
False (*)
True
False (*)
True (*)
False
Correct Correct
3. You can't downcast an object explicitly because you must use virtual method invocation.
True or false? Mark for Review
(1) Points
True
False (*)
Correct Correct
4. Which method will force a subclass to implement it? Mark for Review
(1) Points
Correct Correct
True
False (*)
None of them execute since you cannot have multiple catch statements.
7. Which statements are true when you compile and run this code.(Choose Two)
Compilation succeeds
The class Test compiles if line 6 contains a throws statement. public static void main(String[]
args) throws Exception{ (*)
The class Test compiles if line 7 is enclosed in a try-catch block. try{ sayHello("Java");
}catch(Exception e){} (*)
Correct Correct
True
False (*)
Correct Correct
True (*)
False
Correct Correct
True
False (*)
True
False (*)
Correct Correct
12. Which one of the following would allow you to define an interface for Animal? Mark for
Review
(1) Points
Correct Correct
In an Array you need to know the length and the current number of elements stored.
Section 1
(Answer all questions in this section)
As a Java programmer, we have to call the GC function specifically in order to manage the Java
Memory.
Correct Correct
2. Which of the following allows the programmer to destroy an object referenced by x? Mark
for Review
(1) Points
x.remove();
x.finalize();
x.delete();
Correct Correct
Correct Correct
4. Java allows the same Java program to be executed on multiple operating systems. Mark for
Review
(1) Points
True (*)
False
Correct Correct
5. Which of the following statements describe the Java programming language? Mark for
Review
(1) Points
Java is a high-level programming language.
Correct Correct
Section 1
(Answer all questions in this section)
Variable x resides in the stack area, and variable y resides in the heap of the JVM.
Variable x resides in the heap area, and variable y resides in the stack of the JVM (*)
Variable x stays in the heap area, and variable y resides in the method area of the JVM.
Correct Correct
Section 2
(Answer all questions in this section)
7. The javac command can be used to display native code in Java Mark for Review
(1) Points
True
False (*)
Correct Correct
8. Which of the following commands can be used to translate Java source code into bytecode?
Mark for Review
(1) Points
java
javac (*)
jdb
jstat
Correct Correct
9. Which of the following statements is NOT TRUE for the jdb command? Mark for Review
(1) Points
Correct Correct
10. Like in the Java source code file, one Java class file can contain multiple class definitions.
Mark for Review
(1) Points
True
False (*)
Correct Correct
Section 2
(Answer all questions in this section)
11. Which structure in the Java class file contains the line number information for the original
source file? Mark for Review
(1) Points
method_info (*)
this_class
filed_info
cp_info
Correct Correct
12. The attributes_count item indicates how many attributes are contained within a method.
Mark for Review
(1) Points
True (*)
False
Correct Correct
Section 3
(Answer all questions in this section)
13. Which of the following opcode instructions would add 2 integer variables? Mark for
Review
(1) Points
add
addi
iadd (*)
14. Choose which opcode is used to push an int constant 5 onto the operand stack. Mark for
Review
(1) Points
iconst_5 (*)
idc5
iload_5
iaload_5
iinc5
Correct Correct
15. opcode invokespecial is used to invoke an instance initialization method. Mark for Review
(1) Points
True (*)
False
16. Which of the following is NOT a java class loader? Mark for Review
(1) Points
Correct Correct
17. The Java developer can define a number of additional or custom classloaders. Mark for
Review
(1) Points
True (*)
False
Correct Correct
18. Which of the following exceptions is thrown by the loadClass() method of ClassLoader
class? Mark for Review
(1) Points
IOException
SystemException
ClassFormatError
ClassNotFoundException (*)
Correct Correct
Section 4
(Answer all questions in this section)
19. Which three are valid declarations for a float value? (Choose Three) Mark for Review
(1) Points
float f = 3.0L;
float f = 1.0;
Correct Correct
20. What is the final value of result from the following code snippet?
int i = 1;
int [] id = new int [3];
int result = id [i];
result = result + i; Mark for Review
(1) Points
An exception is thrown.
Correct Correct
Section 4
(Answer all questions in this section)
Correct Correct
int[] myarray={1,2,3,4,5};
int sum=0;
for (int x : myarray)
sum+=x;
System.out.println("sum= " + sum); Mark for Review
(1) Points
10
15 (*)
20
Correct Correct
public Student(){
studentId++;
}
public static int getStudentId(){
return studentId;
}
}
Correct Correct
24. Which ofthe following declarations are wrong?(Choose Three) Mark for Review
(1) Points
Correct Correct
25. Which of the following types are primitive data types? (Choose Two) Mark for Review
(1) Points
String
boolean (*)
double (*)
Integer
Correct Correct
Section 5
(Answer all questions in this section)
True
False (*)
Correct Correct
True
False (*)
Correct Correct
Correct Correct
29. Modeling classes for a business problem requires understanding of the business not Java.
True or false? Mark for Review
(1) Points
True
False (*)
Correct Correct
Correct Correct
Section 5
(Answer all questions in this section)
True
False (*)
Correct Correct
line 7 (*)
line 2
line 3
line 6
Correct Correct
33. 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? Mark for Review
(1) Points
True (*)
False
Correct Correct
34. Which two of the following statements are true? (Choose Two) Mark for Review
(1) Points
Correct Correct
True (*)
False
Correct Correct
Section 5
(Answer all questions in this section)
36. Virtual method invocation must be defined with the instanceof operator.
True or false? Mark for Review
(1) Points
True
False (*)
Correct Correct
37. You can't downcast an object explicitly because you must use virtual method invocation.
True or false? Mark for Review
(1) Points
True
False (*)
Correct Correct
38. Which of the following is the correct way to throw cumstom ServerException? Mark for
Review
(1) Points
throw ServerException
throws ServerException
raise ServerException
Correct Correct
Exception
NullPointerException
Java
Correct Correct
Section 5
(Answer all questions in this section)
41. Which statements are true when you compile and run this code.(Choose Two)
The class Test compiles if line 7 is enclosed in a try-catch block. try{ sayHello("Java");
}catch(Exception e){} (*)
Compilation succeeds
The class Test compiles if line 6 contains a throws statement. public static void main(String[]
args) throws Exception{ (*)
Correct Correct
42. The finally clause only executes when an exception is not caught and thrown.
True or false? Mark for Review
(1) Points
True
False (*)
Correct Correct
43. In what order do multiple catch statements execute? Mark for Review
(1) Points
None of them execute since you cannot have multiple catch statements.
Correct Correct
True
False (*)
Correct Correct
I only
II only
None of these
Correct Correct
Section 5
(Answer all questions in this section)
46. The main purpose of unit testing is to verify that an individual unit (a class, in Java) is
working correctly before it is combined with other components in the system. True or false?
Mark for Review
(1) Points
True (*)
False
Correct Correct
47. Why is it helpful for new programmers to read pre-written code?(Choose Two) Mark for
Review
(1) Points
Correct Correct
In an Array you need to know the length and the current number of elements stored.
Correct Correct
49. 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
Mark for Review
(1) Points
I only
I and II only
None of these
Correct Correct
50. Which of the following statements about arrays and ArrayLists in Java are true?
I. An Array has a fixed length.
II. An Array can grow and shrink dynamically as required.
III. An ArrayList can store multiple object types.
IV. In an ArrayList you need to know the length and the current number of elements stored.
Mark for Review
(1) Points
II and IV only
None of these
14. Why is it helpful for new programmers to read pre-written code?(Choose Two) Mark for
Review
(1) Points
15. Which of the following statements about inheritance is false? Mark for Review
(1) Points
A subclass inherits all the members (fields, methods, and nested classes) from its superclass.
Inheritance allows you to reuse the fields and methods of the super class without having to write
them yourself.
Inheritance allows you to minimize the amount of duplicate code in an application by sharing
common code among several subclasses.
Through inheritance, a parent class is a more specialized form of the child class. (*)
Incorrect Incorrect. Refer to Section 5 Lesson 4.
Section 6
(Answer all questions in this section)
True (*)
False
Correct Correct
2. Which of the following is a list of elements that have a first in last out ordering. Mark for
Review
(1) Points
Arrays
HashMaps
Enums
Stacks (*)
True
False (*)
It is a keyword in Java that restrict the use of the code to local users only.
Something that enables you to create a generic class without specifying a type between angle
brackets <>.
Incorrect Incorrect. Refer to Section 6 Lesson 3.
interface Shape {}
class Circle implements Shape{}
Line 2
Line 4
Line 1
Line 3 (*)
list (*)
enum
set
array
7. The following code is valid when working with the Collection Interface.
Collection collection = new Collection()d;
True or false? Mark for Review
(1) Points
True
False (*)
Correct Correct
1 2 (*)
True (*)
False
Correct Correct
10. What is the correct definition of Enumeration (or enum)? Mark for Review
(1) Points
A keyword that specifies a class whose objects are defined inside the class. (*)
I and II (*)
II only
II and III
I only
III only
It utilizes the "divide and conquer" method, which makes the algorithm more error prone.
It requires incrementing through the entire array in the worst case, which is inefficient on large
data sets. (*)
It involves looping through the array multiple times before finding the value, which is inefficient
on large data sets.
It is never inefficient.
13. Which of the following sorting algorithms utilizes a "divide and conquer" technique to sort
arrays with optimal speed? Mark for Review
(1) Points
Sequential Search
Selection Sort
Binary Search
14. 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? Mark for Review
(1) Points
True
False (*)
Incorrect Incorrect. Refer to Section 6 Lesson 4.
15. A sequential search is an iteration through the array that stops at the index where the
desired element is found.
True or false? Mark for Review
(1) Points
True (*)
False
Correct Correct
Section 6
(Answer all questions in this section)
interface Shape {}
class Circle implements Shape{}
Line 3 (*)
Line 4
Line 1
Line 2
Correct Correct
{1, 1, 2, 22, 305, 26} because a set may contain duplicates and all its elements are of the same
type.
{"Apple", 1, "Carrot", 2} because it records the index of the elements with following integers.
{1, 2, 5, 178, 259} because it contains no duplicates and all its elements are of the same type.
(*)
All of the above are sets because they are collections that can be made to fit any of the choices.
Incorrect Incorrect. Refer to Section 6 Lesson 2.
3. Which code inserted into the code below guarantees that the program will output [1,2]?
import java.util.*;
public class Example{
public static void main(String[] args){
//insert code here
set.add(2);
set.add(1);
System.out.println(set);
}
} Mark for Review
(1) Points
4. Big-O Notation is used in Computer Science to describe the performance of Sorts and
Searches on arrays. True or false? Mark for Review
(1) Points
True (*)
False
Correct Correct
True
False (*)
6. Which of the following sorting algorithms utilizes a "divide and conquer" technique to sort
arrays with optimal speed? Mark for Review
(1) Points
Sequential Search
Binary Search
7. A sequential search is an iteration through the array that stops at the index where the
desired element is found.
True or false? Mark for Review
(1) Points
True (*)
False
Correct Correct
8. Enumerations (enums) are useful for storing data : Mark for Review
(1) Points
True
False (*)
Correct Correct
True
False (*)
Correct Correct
class Test{
public static void main(String[] args){
Node nc=new Node<>();
Comparable com=nc;
}
Mark for Review
(1) Points
True (*)
False
Correct Correct
A pile of pancakes with which you add some to the top and remove them one by one from the
top to the bottom. (*)
A row of books that you can take out of only the middle of the books first and work your way
outward toward either edge.
A line at the grocery store where the first person in the line is the first person to leave.
13. Where you enqueue an element in the list? Mark for Review
(1) Points
True (*)
False
Correct Correct
True (*)
False
Correct Correct
True
False (*)
5. What is special about including a resource in a try statement?(Choose Two) Mark for Review
(1) Points
6. Why should you not use assertions to check parameters? Mark for Review
(1) Points
Assertions can be disabled at run time which may cause unexpected results in your assertions.
(*)
Not all methods have parameters, therefore assertions should never be used on parameters.
15. When an object is able to pass on its state and behaviors to its children, this is called: Mark
for Review
(1) Points
Inheritance (*)
Encapsulation
Polymorphism
Isolation
Home