Soal Final Exam
Soal Final Exam
ference:
String s;
True or false? Mark for Review
(1) Points
True
False
4.
What is printed?
(1) Points
88888
88888888
1010778
101077810109
ArrayIndexOutofBoundsException is thrown
5.
The String methods equals and compareTo perform similar
functions and differ in their return type. True or false?
Mark for Review
(1) Points
True
False
Section 4
(Answer all questions in this section)
6.
You can return to the Eclipse Welcome Page by choosing W
elcome from what menu? Mark for Review
(1) Points
File
Edit
Help
Close
7.
For every opening curly brace { there does not need to b
e a closing curly brace} for the program to compile without error. True or False
?
Mark for Review
(1) Points
True
False
8.
When converting gallons to liters its best to put the ca
lculation result into a variable with a _______________ data type.
Mark for
Review
(1) Points
int
double
boolean
None of the above
9.
What is the purpose of the Eclipse Editor Area and Views
?
Mark for Review
(1) Points
(Choose all correct answers)
To modify elements.
To navigate a hierarchy of information.
To choose the file system location to delete a file.
10.
(1) Points
A combination of views and editors
A combination of views and windows
A combination of editor tabs
None of the above
Section 4
(Answer all questions in this section)
11.
Which of the two diagrams below illustrate the general f
orm of a Java program?
Mark for Review
(1) Points
Example A
Example B
12.
(1) Points
Defines where this class lives relative to other classes, and provides a
level of access control.
Provides the compiler information that identifies outside classes used w
ithin the current class.
Precedes the name of the class.
13.
2
2.5
6
14
14.
Mark for
Review
(1) Points
Numbers and characters
True and false
Relational and logic operators
Arithmetic and logic operators
Integers and floating point types
Section 5
(Answer all questions in this section)
15.
Review
(1) Points
Mark for
>,<,=,!,<=,>=
>,<,==,!=,<=,>=
>,<,=,!=,<=,>=
>,<,=,!=,=<,=>
Section 5
(Answer all questions in this section)
16.
f statement?
if (balance < 500)<
fee = 10;
else
fee = 0;
Mark for Review
(1) Points
fee = ( balance < 500) ? 0 : 10;
fee= ( balance < 500) ? 10 : 0;
fee = ( balance >= 5) ? 0 : 10;
fee = ( balance >= 500) ? 10 : 0;
fee = ( balance > 5) ? 10 : 0;
17.
18.
Updating the input of a loop allows you to implement the
code with the next element rather than repeating the code always with the same
element. True or false?
Mark for Review
(1) Points
True
False
19.
In a for loop the counter is not automatically increment
ed after each loop iteration. Code must be written to increment the counter. Tru
e or false?
Mark for Review
(1) Points
True
False
20.
When the for loop condition statement is met the constru
ct is exited. True or false?
Mark for Review
(1) Points
True
False
21.
Why might a sequential search be inefficient?
(1) Points
It utilizes the "divide and conquer" method, which makes the algorithm m
ore error prone.
It requires incrementing through the entire array in the worst case, whi
ch 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.
22.
A sequntial search is an iteration through the array tha
t stops at the index where the desired element is found. True or false?
Mark for Review
(1) Points
True
False
23.
Selection sort is efficient for large arrays. True or fa
lse?
Mark for Review
(1) Points
True
False
24.
Which of the following is the correct lexicographical or
der for the conents of the int array?
{17, 1, 1, 83, 50, 28, 29, 3, 71, 22}
(1) Points
s of the one dimensional array prices, and then prints the sum to the screen?
Mark for Review
(1) Points
int total = 0;
for(int i = 0; i total+=prices[i];
int total = 0;
for(int i = 0; i total+=prices[i];
System.out.println(total);
int total = 0;
for(int i = 1; i total = total+prices[i];
System.out.println(prices);
int total = 0;
for(int i = 0; i total+=prices[i];
System.out.println(prices);
27.
Which of the following declares and initializes a one di
mensional array that can hold 5 Object reference types?
Mark for Review
(1) Points
String[] array=new String[5];
Object array=new Object[5];
Object[] array=new Object[4];
String[] array=String[4];
28.
The following segment of code initializes a 2 dimensiona
l array of primitive data types. True or false?
double[][] a=new double[4][5]; Mark for Review
(1) Points
True
False
29.
int num[]={9,8,7,6,5,4,3,2,1};
for(int i=0;i<9;i=i+3)
System.out.print(num[i]);
Mark for Review
(1) Points
9630
963
987654321
97531
This code doesn't compile.
Section 7
(Answer all questions in this section)
30.
All objects, in Java, are created using int. True or fal
se?
Mark for Review
(1) Points
True
False
Section 7
(Answer all questions in this section)
31.
The basic unit of encapsulation in Java is the primitive
data type. True or false?
Mark for Review
(1) Points
True
False
oolean value?
(1) Points
32.
Which of the following creates a method that returns a b
Mark for Review
below?
Mark for Review
(1) Points
ThisClass t=new ThisClass();
ThisClass t;
ThisClass t=new ThisClass(3,4);
ThisClass t=new ThisClass(5);
34.
What is Polymorphism?
(1) Points
A way of redefining methods with the same return type and parameters.
A way to create multiple methods with the same name but different parame
ters.
A class that cannot be initiated.
The concept that a variable or reference can hold multiple types of obje
cts.
38.
(1) Points
(Choose all correct answers)
It is the highest superclass.
It extends other classes.
Mark for
Review
(1) Points
(Choose all correct answers)
protected
public
secured
default (no access modifier)
private
45.
uctor. True or False?
(1) Points
True
False
Section 7
(Answer all questions in this section)
46.
argument method?
(1) Points
Having more than one constructor with the same name but different argume
nts.
A type of argument that enables calling the same method with a different
number of arguments.
47.
If a variable in a superclass is private, could it be di
rectly accessed or modified by a subclass? Why or why not?
Mark for Review
(1) Points
Yes. A subclass inherits full access to all contents of its super class.
Yes. Any variable passed through inheritance can be changed, but private
methods cannot.
No. A private variable can only be modified by the same class with which
it is declared regardless of its inheritance.
No. Nothing inherited by the super class can be changed in the subclass.
48.
(1) Points
(Choose all correct answers)
It is the virtual machine that translates Java code into a representatio
n that the computer can understand.
A web-based Java program that is embedded into a web browser.
A graphic visual included in Java.
There is no such thing as a Java Applet.
49.
(1) Points
A keyword that allows or restricts access to data and methods.
A programming philosophy that promotes simpler, more efficient coding by
using exiting code for new applications.
A structure that categorizes and organizes relationships among ideas, co
ncepts of things with the most general at the top and the most specific at the b
ottom.
A programming philosophy that promotes protecting data and hiding implem
entation in order to preserve the integrity of data and methods.
50.
If you inherit a class, you do not inherit the class' co
nstructors. True or false?
Mark for Review
(1) Points
True
False