Enthuware Flashcards
Can a catch block follow a finally block?
No, the order is always try/catch/finally
If you just change a return type of a method, is this proper overloading?
No, you can’t just change the return type, you must change some of the parameters
What does flow control mean?
A for loop
int [] [] [] ia = new int [7] [3] [5]
What will ia.length output?
7
length doesn’t determine the dimensions but will do the length of the first array
For strings created with non-strings, what must part of the creation to ensure successful compilation?
Part of it must be a string
Will this compile?
new Short(9)
No, no constructor in Short wrapper class will take int value
What must s be?
s instanceOf Short
s must be an object
Is StringBuilder a final class?
Yes
What are all methods of String?
Final
What does byte * byte return?
int
What will this output be?
short += int
It will do a cast to short
For overridden methods, what must the return be?
It must be the same of the covarient (subclass)
What is happening here?
return (long) b3 / d * 3
Cast applies only to b3, not whole computation
Can continue occur inside a switch statement?
No
Where can breaks occur?
Switch statement While Do For Enhanced For
Can constructors have a return type
No
If method is called by super() in constructor, which method should be used, the object method or the reference method?
The object method!
Is this ok?
public static void do(){//many lines of code}
No, do is a reserved word
What is the protection hierarchy?
public
protected
default
private
What is a trim - a String method or a StringBuilder method?
A String method
What is append - a String method or a StringBuilder method?
A StringBuilder method
What is meant by a virtual call?
A call made at runtime
What is the range of bytes?
-128 to 127
What are the two things you must ensure when throwing?
- it is within a valid try-catch statement
- method has a throws clause