Java2

Is this your test? Login to manage it. If not, you can generate an exam just like it.

This is a non-interactive preview of the quiz content.

1.
1 point
When importing another package into a class you must import the entire package as well as the package classes that will be called.
2.
1 point
The following defines a class keyword:
3.
1 point
The six relational operators in Java are:
4.
1 point
A counter used in a for loop cannot be initialized within the For loop statement.
5.
1 point
Which of the following statements correctly assigns "3 times 10 to the 4th power" to the variable number?
6.
1 point
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.
7.
1 point
What is one significant difference between a while loop and a do-while loop?
8.
1 point
Which of the following are types of loops in Java?
9.
1 point
Which of the following defines a driver class?
10.
1 point
How would you use the ternary operator to rewrite this if statement?
if (gender == "male")
System.out.print("Mr.");
else
System.out.print("Ms.");
11.
1 point
Which line of Java code properly calculates the volume of a cone using
v=1/3 pi r2 h
where r and h are Java primitive integers?
12.
1 point
It is necessary to end all loops at some point in your Java program.
13.
1 point
For both the if-else construct and the for loop, it is true to say that when the condition statement is met, the construct is exited. True or False?
14.
1 point
In Java, each case segment of a switch statement requires the keyword break to avoid "falling through".
15.
1 point
What will the method methodA print to the screen?
public Class A
{
int g=5;//global variable
public void methodA()
{
int g=6;
System.out.println(g*3);
}
}
16.
1 point
The three logic operators in Java are:
17.
1 point
The == operator can be used to compare two String objects. The result is always true if the two strings are identical.
18.
1 point
In a for loop, the counter is automatically incremented after each loop iteration. True or False?
19.
1 point
Determine whether this boolean expression evaluates to true or false:
!(3<4&&5>6||6<=6&&7-1==6)
20.
1 point
How would you use the ternary operator to rewrite this if statement?
if (skillLevel > 5)
numberOfEnemies = 10;
else
numberOfEnemies = 5;
21.
1 point
Identify which situation could be an example of a while loop.
22.
1 point
Consider the following code snippet. What is printed?
String ocean = new String("Atlantic Ocean");
System.out.println(ocean.indexOf('a'));
23.
1 point
Eclipse provides views to help you navigate a hierarchy of information.
24.
1 point
Eclipse provides an edit area to help you navigate a hierarchy of information.
25.
1 point
The String methods equals and compareTo perform the exact same function.
26.
1 point
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); }
}
}
27.
1 point
In an if-else construct, the condition to be evaluated must be contained within parentheses.
28.
1 point
What is the function of the word "break" in Java?
29.
1 point
When Eclipse launches, the Welcome page displays. Once this page is closed you cannot return to the resources available on this page.
30.
1 point
What is the difference between the symbols = and == ?
31.
1 point
What is a loop?
32.
1 point
Which of the following correctly initializes a for loop that executes 5 times?
33.
1 point
Given the following declaration: int z=5,m=6;
Which line of Java code properly casts one type into another without data loss?
34.
1 point
Which of the following correctly initializes an instance of Scanner, called "in", that reads input from the console screen?
35.
1 point
The following code fragment properly implements the switch statement. True or false?
default(input)
switch '+':
answer+=num;
break;
case '-':
answer-=num;
break;
!default
System.out.println("Invalid input");