![]() |
|
answer to question 6)
2) the instanceof operator can be used to determine if a reference is an instance of a particular primitive wrapper classthe instanceof operator can only be used to make a static comparison with a class type. java1.1 added the isinstance method to the class class to allow you to dynamically determine a class type. the exam does not test you on isinstance.
answer to question 7)
2) interfaces cannot have constructors
if you try to create a constructor for an interface the compiler will give you an error message something like
"interface can't have constructors".
4) interfaces are the java approach to addressing the single inheritance model, but require implementing classes to create the functionality of the interfaces.
an interface may contain variables as well as methods. however any variables are final by default and must be assigned values on creation. a class can only extend one other class (single inheritance) but may implement as many interfaces as you like (or is sensible).
answer to question 8)
none of these are valid statements. the math class is final and cannot be extended. the max method takes two parameters, round only takes one parameter and there is no mod parameter. you may get questions in the exam that have no apparently correct answer. if you are absolutely sure this is the case, do not check any of the options.
answer to question 9)
1) the runnable interface has only one method run that needs to be created in any class that implements it. the start method is used to actually call and start the run method executing.
answer to question 10)
1) a byte can represent between -128 to 127
the char type is the only unsigned type in java and thus cannot represent a negative number.
for more information on this topic go to
answer to question 11)
2) compilation and no output at runtime
because the method in base called base has a return type it is not a constructor and there for does not get called on creation of an instance of its child class in
for more information on this topic go to
answer to question 12)
4) compilation and output of hello
this type of question is particularly calculated to catch out c/c++ programmers who might expect parameter zero to be the name of the compiler.
for more information on this topic go to