Quiz Oracle Section 4
1. When
Eclipse launches, the Welcome page displays. Once this page is closed you
cannot return to the resources available on this page. True or False?
True False
(*)
2. Eclipse
provides an edit area to help you navigate a hierarchy of information. True or
False?
True False
(*)
3. Eclipse
provides views to help you navigate a hierarchy of information. True or False? True (*) False
4. Tabs are
used when more than one file is open in the edit area. True or False?
True (*) False
5. A
perspective is described as: Mark for
Review
o
A combination of views and editors (*)
o
A combination of views and windows
o
A combination of editor tabs
o
None of the above
6. The
______________ is the location onto which you will store and save your files.
o
Perspective
o
Workspace (*)
o
Editor
o
None of the above
7. A
workspace can have one or more stored projects. True or false?
True (*) False
8. Identify
the components in the image below.
·
· A-Main
Method, B-Class, C-Package
· A-Class,
B-MainMethod, C-Package
· A-Package,
B-Main Method, C-Class (*)
· None of
the above
9. In
Eclipse, when you run a Java Application, the results may be displayed in the
Console View. True or False?
True (*) False
11. When
importing another package into a class you must import the entire package as
well as the package classes that will be called. True or False?
True False (*)
11. A
counter used in a For loop cannot be initialized within the For loop statement.
True or False?
True False
(*)
12. The
syntax below represents a valid initialization of a For loop counter. True or
False?
public
class ForLoop {
public static void main (String args[])
{
for
(int i=10; i <20; i++)<
{System.out.println("i:
"+i); }
}
}
True (*) False
13. In a For
loop, the counter is automatically incremented after each loop iteration. True
or False?
True False (*)
14. In an
if-else construct, the condition to be evaluated must be contained within
parentheses. True or False?
True (*) False
15. Which of
the two diagrams below illustrate the correct syntax for variables used in an
if-else statement?
Example A* Example B
16. Which of
the two diagrams below illustrate the general form of a Java program?
Example A Example B*
17. The six relational
operators in Java are:
·
>,<,=,!,<=,>=
·
>,<,=,!=,=<,=>
·
>,<,=,!=,<=,>=
·
>,<,==,!=,<=,>= (*)
18. Determine
whether this boolean expression evaluates to true or false:
!(3<4&&5>6||6<=6&&7-1==6)
True False (*)
19. The
three logic operators in Java are:
·
!=,=,==
·
&&, ||, ! (*)
·
&&,!=,=
·
&,|,=
20. What
will print if the following Java code is executed?
0 3 (*) 4 5
21. What is
the difference between the symbols = and == ?
·
The symbol = is used in if statements
and == is used in loops.
·
The symbol == is used to assign values
to variables and the = is used in declarations.
·
The = is use to assign values to
variables and the == compares values. (*)
·
There is no difference.
22. What is
the output of the following lines of code?
int
j=7,k=5,m=8,result; result=j/m*k; System.out.println(result);
0 (*) 4.375 0.175 280
23. What is
the output of the following lines of code?
int
j=7,k=5,m=8,result; result=j-k%3*m; System.out.println(result);
0 16 2 -9 (*)
24. What is the output of the following
lines of code?
int
j=6,k=8,m=2,result;
result=j-k%3*m;
System.out.println(result);
-42
0
2
(*)
6
25. Which of
the following is not correct Java code?
·
double x=Math.sqrt(16);
·
double x=Math.pow(3,4)*5.0;
·
double x=Math.PI*5.0;
·
double x=Math.pow; (*)
26. Which line
of Java code assigns the value of 5 raised to the power of 8 to a?
·
double a=15^8;
·
double a=Math.pow(5,8); (*)
·
int a=Math.pow(8,5);
·
int a=Math.pow(5,8);
·
double a=pow(8,5);
27. Write a
declaration statement that will hold a number like 2.541.
·
char number;
·
int number;
·
float number; (*)
·
boolean number;
28. Which of
the following is the name of a Java primitive data type?
·
String
·
int (*)
·
Rectangle
·
Object
29. Which of
the following is not a legal name for a variable?
·
R2d2
·
dgo2sleep
·
4geeks (*)
·
to_be_or_not_to_be
30. Which of
the following examples of Java code is not correct?
·
int x=6;
·
double d=4.5;
·
boolean b=1; (*)
·
char c='r';
31. Which of
the following statements correctly assigns "3 times 10 to the 4th
power" to the variable number?
·
double number=3*10^4;
·
double number=3(e4);
·
double number=3e4; (*)
·
double number=3*10e4;
32. Which
line of code does not assign 3.5 to the variable x?
·
double x=3.5
·
x=3.5;
·
3.5=x; (*)
·
x=7.0/2.0;
33. Consider
the following:
You are writing a class and are using a
global variable. Inside a method you declare a local variable with the same
name as the global variable.
This programming style is poor because
inside the method the global variable will have precedence over the local
variable with the same name.
True or false?
True False (*)
34. What
will the method A print to the screen?
18 (*)
15
6
3
35. Which
line of Java code properly calculates the volume of a cone using
where r and h are Java primitive integers?
·
double V=1/3*3.14*r*r*h;
·
double
V=(double)1/3*Math.PI*Math.pow(r,2)*h; (*)
·
double V=1/3*Math.PI*Math.pow(r,2)*h;
·
double
V=(double)1/3*Math.PI*Math.pow(2,r)*h;
·
double V=1/3*3.14*r(2)*h;
36. Given
the following declaration: int z=5,m=6;
Which line of Java code properly
casts one type into another without data loss?
·
double x=(double)z/m; (*)
·
double x=z/m;
·
double x=(double)(z/m);
·
double x= double z/m;
37. What will the following code segment
output?
"\\" (*)
"\\\"
\"\\\\\"
"\\\\\"
38. The String methods equals and
compareTo perform similar functions and differ in their return type. True or
false?
True
(*) False
39. Consider the following code snippet.
What is printed?
String
river = new String("Hudson");
System.out.println(river.length());
8
7
Hudson
river
6 (*)
40. Which of the following defines a
driver class?
Contains
a main method and other static methods. (*)
Contains classes that define objects.
Contains a main method, a package, static methods, and classes that define
objects.
None of the above.
41. The following defines a class
keyword:
Provides
the compiler information that identifies outside classes used within the
current class.
Precedes the name of the class. (*)
Defines where this class lives relative to other classes, and provides a level
of access control.
42. Which of the two diagrams below
illustrate the general form of a Java program?
Example A
Example B (*)
43. What two values can a boolean
variable have?
Relational
and logic operators
Arithmetic and logic operators
True and false (*)
Numbers and characters
Integers and floating point types
44. Which line of Java code assigns the
value of 5 raised to the power of 8 to
a?
int a=Math.pow(5,8);
double a=Math.pow(5,8); (*)
double a=15^8;
int a=Math.pow(8,5);
double a=pow(8,5);
45. What is the output of the following
lines of code?
int
j=6,k=8,m=2,result;
result=j-k%3*m;
System.out.println(result);
-42
2 (*)
6
0
46. For every opening curly brace {
there must be a closing curly brace} or the program will not compile without
error. True or False?
True
(*) False
47. You can return to the Eclipse
Welcome Page by choosing Welcome from what
menu?
Close
Edit
File
Help (*)
48. Tabs are used when more than one
file is open in the edit area. True or
False?
True (*) False
49. Which line of code does not assign
3.5 to the variable x?
3.5=x;
(*)
x=7.0/2.0;
double
x=3.5
x=3.5;
50. A local variable has precedence over
a global variable in a Java method. True or
false?
True
(*) False
51. What does the following program
output?
"total
cost: " 48
total cost: 48
"total cost: " 40
total cost: + 40
total cost: 40 (*)
52. The ______________ is the location
into which you will store and save your files.
Perspective
Workspace
(*)
Editor
None
of the above
53. What symbols are required for a
compiler to ignore a comment?
/*/
/*
*/
//
(*)
54. The following program prints
"Equal". True or false?
True False (*)
55. Suppose that s1 and s2 are two
strings. Which of the statements or expressions are valid?
Choose
all correct answers)
String
s3 = s1 + s2; (*)
String
s3 = s1 - s2;
s1.compareTo(s2);
(*)
int
m = s1.length(); (*)
s1
<= s2
56. Declaring and instantiating a String
is much like any other type of variable. However, once instantiated, they are
final and cannot be changed. True or false?
True (*) False
57. The following defines a package
keyword:
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 within
the current class.
Precedes the name of the class.
58. The following defines a class
keyword:
Provides
the compiler information that identifies outside classes used within the
current class.
Precedes
the name of the class. (*)
Defines
where this class lives relative to other classes, and provides a level of
access control.
59. Match each of the following literals
('x', 10, 10.2, 100L, "hello") with its respective data type.
char,
boolean, float, long, String
char,
double, int, long, String
char,
int, long, float, String
boolean,
byte, int, long, Short
char,
int, double, long, String (*)
60. Which line of Java code will assign
the value of the square root of 11 to a variable named
a?
int
a=Math.sqrt(11);
double
a=11^(1/2);
double
a=Math.sqrt*11;
double
a=Math.sqrt(11); (*)
double
a=sqrt(11);
61. Which of the following statements
displays 12345?
I.
System.out.println( 123 * 100 + 45);
II.
System.out.println("123" + 45);
III.
System.out.println( 12 + "345");
All
of the above. (*)
I
only.
I
and II only.
II
and III only.
None
of the above.
62. Select the declaration and
initialization statement that will hold the letter J
String
letter='J';
char
letter='J'; (*)
int
letter='J';
float
letter='J';
63. For every opening curly brace {
there does not need to be a closing curly brace} for the program to compile
without error. True or False?
True False (*)
64. Two variables are required to
support a conversion of one unit of measure to another unit of measure. True or
False?
True
(*) False
65. The == operator can be used to
compare two String objects. The result is always true if the two strings are
identical. True or false?
True False (*)
66. Consider the following code snippet
String
forest = new String("Black");
System.out.println(forest.length());
What
is printed?
Forest
7
6
Black
5
(*)
67. The following program prints
"Equal". True or false?
True
(*) False
68. The following defines a package
keyword:
Provides
the compiler information that identifies outside classes used within the
current class.
Defines
where this class lives relative to other classes, and provides a level of
access control. (*)
Precedes
the name of the class.
69. In Eclipse, when you run a
Java Application, the results are displayed in a new window. True or
False?
True False (*)
70. Multiple windows are used when more
than one file is open in the edit area. True or
False?
True False
(*)
71. What is the purpose of the Eclipse
Editor Area and Views?
(Choose all correct answers)
To
choose the file system location to delete a file.
To
modify elements. (*)
To
navigate a hierarchy of information. (*)
72. The following defines an import
keyword:
Precedes
the name of the class.
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 within the
current class. (*)
73. The following code is an example of
creating a String reference:
String s;
True or
false?
True (*) False
74. Which of the following statements
declares a String object called name?
String
name; (*)
String
name
double
name;
int
name;
75. Given the code below, which of the
following would equate to true?
String s1
= "yes";
String
s2 = "yes";
String
s3 = new String(s1);
(Choose
all correct answers)
s1
== s2 (*)
s3.equals(s1)
(*)
s1.equals(s2)
(*)
s1
= s2
s3
== s1
76. Which line of Java code properly
calculates the area of a triangle using A=1/2(b)(h) where b and h are Java
primitive integers?
double
A=1/2bh;
double
A=(double)1/(double)2*b*h; (*)
double
A=(double)(1/2)*b*h;
double
A=1/2*b*h;
77. Which of the following is not a
legal name for a variable?
theLastValueButONe
zero
year2000
2bad
(*)
78. What is the purpose of the Eclipse
Editor Area and Views?
(Choose
all correct answers)
To
modify elements. (*)
To
choose the file system location to delete a file.
To
navigate a hierarchy of information. (*)
79. A _______________ is used to
organize Java related files.
Project
Collection
Package
(*)
Workspace
80. Which of the two diagrams below
illustrate the general form of a Java program?
Example A Example B (*)
81. Which of the two diagrams below
illustrate the general form of a Java program?
Example A Example B (*)
82. Examine the following code:
What is the value of variable
x?
14
2 (*)
6
2.5
83. Which of the following is not
correct Java code?
double
x=Math.pow; (*)
double
x=Math.sqrt(16);
double
x=Math.pow(3,4)*5.0;
double
x=Math.PI*5.0;
84. What is printed by the following
code segment?
\\\\\\\\\\\\\\
\\\\
\\\\\\\ (*)
\\
85. Consider the following code snippet.
What
is printed?
AtlanticPacificIndianArcticSouthern
Code does not compile
87658
55555
ArrayIndexOutofBoundsException is thrown (*)