Font size
WorksheetsJAVA: Level-1
Total questions: 15
Worksheet time: 11mins
Choose from below non-mandatory (not MUST) component of a Java Program.
Class name
main method
print method
All of the above
Choose correct signature of main method.
public static int main(String[] args)
private static void main(String[] args)
public static void main(int[] args)
public static void main(String[] args)
In Java Array, index starts from
1
0
-1
-2
What will be output of following code -
public static void main(String[] args) {
System.out.print("Hello");
System.out.println("How are you?");
}
Error
Hello
How are you?
HelloHow are you?
How are you?Hello
In Java, which of the following Loop executes at least once -
for Loop
while Loop
do...while Loop
None of the above
What will be the output of following code -
public static void main(String[] args) {
byte b = 135;
System.out.println(b * 2);
}
135
270
135 * 2
Compilation Error
to assign a value as "2.5", which data type I can use
int
boolean
char
float
what will be the output of following program -
public static void main(String[] args) {
char c = 65;
System.out.println(c);
}
A
65
Compilation Error
c
Which of the following is not a valid comparison operator -
<
>
!=
=
In the following Java program how many times "Hello!" will get printed -
public static void main(String[] args) {
for(int i=0; i <=5; i++) {
System.out.println("Hello!");
}
}
4
5
6
7
Choose which data type is a Java class -
int
long
String
boolean
which statement will help to identify if content of string1 and string2 is exactly the same
string1 == string2
string1.equals(string2)
string1.equalsIgnoreCase(string2)
All of the above
In following program, how many "Hello!" will get printed -
public static void main(String[] args) {
for(int i=6; i <=5; i--) {
System.out.println("Hello!");
}
}
0
1
2
Infinite
In following program, how many "Hello!" will get printed -
public static void main(String[] args) {
int i = 0;
while(i <=5) {
System.out.println("Hello!");
}
}
0
5
6
infinite
What will be the output of following program -
public static void main(String[] args) {
String s1 = new String("Amol");
String s2 = new String("Amol");
System.out.println(s1 == s2);
}
s1 == s2
true
false
compilation error
