Which three are valid types for switch?
Correct Answer:
ADE
A switch works with the byte, short, char, and int primitive data types. It also works with enumerated types theString class, and a few special classes that wrap certain primitive types: Character, Byte, Short, and Integer.
Given the fragment:<>
Correct Answer:
A
Given the code fragment:<>
Correct Answer:
B
The outer loop will run three times, one time each for theelements in table. The break statement breaks the inner loop immediately each time.
2 will be printed once only.
Note: If the line int ii = 0; is missing the program would not compile.
Given:
< ><>>>< >
Correct Answer:
D
Which two may precede the word ‘class’ in a class declaration?
Correct Answer:
BC
B: A class can be declared as public or private.
C: You can declare two kinds of classes: top-level classes and inner classes.
You define an inner class within a top-level class.Depending on how it is defined, an inner
class can be one of the following four types:Anonymous, Local, Member and Nested top- level.
A nested top-level class is a member classes with astaticmodifier. A nested top-level class is just like any other top-level class except that it is declared within another class or interface. Nested top-level classes are typically used as a convenient way to group related classes without creating a new package.
The following is an example:
public class Main { staticclass Killer {