Font size
WorksheetsJava March
Total questions: 16
Worksheet time: 9mins
What will be the Result if we try to compile and execute this
class Test{
public static void main(String[] ar){
double d=1.2D;
System.out.println(d);
}
}
Compilation Error
1.2
1.2D
d
What is the extension for java?
(a)
Which of these is the correct way to name a variable?
45632
4variable
player_Name
player name
What does a comment look like in Java?
//comment
#comment
comment
**comment**
Which of these is an input device?
Speaker
Microphone
Monitor
Printer
Which of these is an output device?
Trackpad
Mouse
Monitor
Keyboard
What will the output be from the following code?
int a = 2
System.out.println("Hello" + a + "world!")
Hello Hello world! world!
Hello 2 world!
Hello2world!
Helloaworld!
What is the problem with this code?
Line 1: String myName = "Mary Jacobson";
Line 2: System.out.println ("My name is " + myname);
Line 2: should be System.out.println ("My name is myName");
Line 2: should be System.out.println ("My name is " + myName);
There is no problem with the code
Line 2: should be System.out.display("My name is " + myname);
Which of the following is a valid variable declaration in Java?
int my Integer= 0;
int int = 0;
int myInteger = 0;
int 1myInteger = 0;
int x = 10;
x = x + 5;
System.out.println(x);
10x
x5
15
5
int sum1 = 100 + 50;
int sum2 = sum1 + 250;
int sum3 = sum2 + sum2;
System.out.println(sum3);
What will be the final output?
sum3
800
950
250
int x = 5;
int y = 6
int z = 50;
System.out.println(x + y + z);
5
61
6
xyz
What is right way of defining String variable?
String name = John;
String name = "John";
String name = "John"
string name = "John";
Which of the following is NOT a data types in java
Boolean
int
java
String
What is at the end of a line of code?
,
;
x
.
When we want to print in Java, we use the code ......
