The Ultimate and genuinely amazingly awesome hard Java Test

Why does this statement not work like expected? (if(“bla”==”bla”))


What needs to be inserted into “var” to make this code return the boolean value true?

public boolean method() {

if(!var) {

return true;

} else {

return false;

}

}


What does this code output if run:

class Loop {

public static void main(String[] args) {

int i;

loop1:

while (true) {

if (i++ > 4) {

break loop1;

}

loop2:

while (true) {

if (++i < 2) {

continue loop2;

} else if (i++ > 2) {

break loop2;

} else if (i-- == 2) {

break loop1;

}

break loop2;

}

}

System.out.println(i);

}

}


What is the output?

public class Holiday {

public static void main(String[] args) {

String s1 = "ARE YOU ";

s1 += "ON HOLIDAY?";

s1.intern();

String s2 = "ARE YOU ON HOLIDAY?";

System.out.print((s1 == s2) + " ");

System.out.println(s1.equals(s2));

}

}


What exceptions have to be handled for a program to compile?


What is the output?

class Calculator {

int var = -1;

public static void main(String[] args) {

new Calculator().calculate();

}

void calculate() {

var += ++var/var++;

System.out.println(var);

}

}


What does the “implements” keyword specify when used after a classes name?


What happenes when you copile this code and then excecute it?


How can you check if an object is of a certain type?


What is the output when you compile and execute this code?

class Geryon {

static { System.out.print("a"); }

Geryon() { System.out.print("c"); }

public static void main(String[] args) {

System.out.print(new Geryon());

}

}


What is the rule for naming a constructor ?


What is the output if you execute this code?

public class Satyren {

public static void main(String[] args) {

int result;

long a = 1000;

long b = 0200;

long c = 0x40;

result = a+b+c;

System.out.println(result);

}

}


What happens to Java Code when compiled ?


What is the output if you excecute this code?

public class Tityos {

public static void main(String[] args) {

int a = 1;

int b = 1;

int c = 1;

int d = 1;

int e = 1;

System.out.println((a + b) + c + (d + e));

}

}


What component is referred to as the CU in a CPU?











































































































Description:

This is a test about Java devised by two IB Computer Science students. It is designed to test if a participant understands Java Syntax and the principle of code execution. Take it and see what questions you get right. For corrections please PM me. So go now, you only have 15 minutes to complete this exercise.

Comments

Want to learn?

Sign up and browse through relevant courses.

or fill this simple form
Name:
Your Email:
Password:
Country:
Contact no.:


Area code Number
Subjects you are interested in:
Word verification: (Enter the text as shown in image)


Sign Up Already a member? Sign In
I agree to WizIQ's User Agreement & Privacy Policy
1 Follower
Test: 1

Your Facebook Friends on WizIQ

Connect