Operators and Decision Constructs Flashcards
Which types can be used as switch variables?
String, byte, char, short, int, and enum, as well as their respective wrapper classes.
T/F: Case constants must be assignable to the switch variable.
True.
T/F: If the switch variable is of the String type, you can still use int
for the case labels
False.
Will this compile:
byte b = 10;
switch(b) {
case 300: //valid code;
}
No.
The case constants cannot be bigger than what the switch variable can store.
Can there be more than one case constant with the same value in a switch statement?
No.
T/F: There can be multiple labels for a a switch statement.
False.
Which operators will not necessarily evaluate all operands?
||
? :
&&
What are the integral types?
byte, short, int, long, and char.
These are primitive types which can holder integer values.
T/F: The modulus operator can only be used on integer operands.
False.
It can also be used on floating point operands.
Is this statement legal:
if (false) ; else ;
Yes.
An if-clause and else-clause can have empty statements.
T/F: An abstract class can be extended by an abstract class or a concrete class
True
T/F: A concrete class can be extended by an abstract or concrete class.
True
T/F: An Interface can be extended by another interface
True
T/F: An interface can be extended by an abstract class.
False.
A class implements an interface, not extend.
T/F: An interface can be extended by a concrete class.
False.