Join Now
Home Aptitude Reasoning DI VA GK CA CA Hindi Quiz Placements
int
boolean
double
string
What is the output of the following code?
public class Test { public static void main(String args[]) { int x = 10; int y = 5; if(x > y) { System.out.println("x is greater than y"); } else { System.out.println("x is less than or equal to y"); } } }
x is greater than y
x is less than or equal to y
Both statements are printed
No output
What is Java?
A programming language
An operating system
A database management system
A web browser
myVariable
$variable
2variable
_variable
public class Test { public static void main(String args[]) { System.out.println("Hello" + " World"); }
Hello
World
Hello World
HelloWorld
public class Test { public static void main(String args[]) { int x = 10; int y = 5; int z = x + y; System.out.println("The sum of " + x + " and " + y + " is " + z); } }
The sum of 10 and 5 is 15
The sum of x and y is z
The sum of x and y is 15
Implementing the Runnable interface
Extending the Thread class
Calling the start() method on a Thread object
Creating a new instance of the Thread class
public class Test { public static void main(String args[]) { int x = 5; int y = 2; System.out.println(x / y); } }
2
2.5
None of the above
public class Test { public static void main(String args[]) { String name = "Java"; System.out.println(name.substring(1, 3)); } }
Ja
av
Jav
public class Test { public static void main(String args[]) { String name = "Java"; for(int i = 0; i < name.length(); i++) { System.out.print(name.charAt(i) + " "); } } }
J a v a
Java
Jv