Sun Certified
Programmer for the Java2 Platform
Mock Exam
byte b; int i = 10; long l = 20;
___________________________________
char a; Which of the following are valid values that can be assigned to a?
In base amethod In child another Value of staticInt is 30 Value of instanceVar is 40
In base amethod In child another Value of staticInt is 10 Value of instanceVar is 20
In child amethod In child another Value of staticInt is 30 Value of instanceVar is 40
ANSWERS:-
Remember, that a compound assignment expression of the form E1 op= E2 is always equivalent to E1 = (Type) (E1 op E2), where Type is the type of E1.
The only modifiers that are allowed with interface methods are public and abstract. And these are implicit, so you dont even have to include them.
All three are right. Classes defined within an interface are implicitly public and static and because you cannot have static methods within an iterface, you cannot refer to the non-static methods from the static class methods.
The only operators that can cause an ArithmeticException are the integer division (/) and modulo (%) operators. Remember that float operations do not raise any exception at all. They may result in NaN or Infinities, instead.
-0.0 > 0.0 returns false
Check out the Java Language Specification for more information on Character Literal and Escape Sequences
Static variables and methods as well as instance variables use the Type of the reference variable to determine the correct variable/method to use. On the other hand, instance methods use the Class of the reference variable to determine the correct method to call
Unlike methods, a constructor cannot be abstract, static, final, strictfp, native or synchronized. Related: Do you have a Java Problem?Ask It in The Java Forum Java Books
Return to : Java Programming Hints and Tips All the site contents are Copyright © www.erpgreat.com
and the content authors. All rights reserved.
|