Categories
4 Multiple Choices of Java
Date
Author
Java – Static Analysis
What is the output of the following Java code?
public class Test { public static void main(String[] args){ int i = 010; int j = 07; System.out.println(i); System.out.println(j); } }
Will This Compile?
Given the follow code, which are true? (Choose all that apply):
1. interface Syrupable { 2. void getSugary(); 3. } 4. abstract class Pancake implements Syrupable { } 5. 6. class BlueBerryPancake implements Pancake { 7. public void getSugary() { ; } 8. } 9. class SourdoughBlueBerryPancake extends BlueBerryPancake { 10. void getSugary(int s) { ; } 11. }
Static Code Analysis
What will the output be?
try
{
Float f1 = new Float("3.0");
int x = f1.intValue();
byte b = f1.byteValue();
double d = f1.doubleValue();
System.out.println(x + b + d);
}
catch (NumberFormatException e) /* Line 9 */
{
System.out.println("bad number"); /* Line 11 */
}
Which of the following is not a correct way of commenting?
Which of the following is not a correct way of commenting?