Questions and Answers Already Graded
A
What will be the output of `System.out.println(6 + "3");`?
A. 63
✔✔B. 63
C. 9
D. Compilation error
What is the default value of a `float` variable in Java?
A. 0
✔✔B. 0.0
C. 0.0f
D. 0.0d
How do you declare a constant in Java?
A. `int x = 10;`
✔✔B. `final int x = 10;`
1
,C. `constant int x = 10;`
D. `x = final 10;`
Which of the following is a valid way to declare a `String` in Java?
✔✔A. `String name = "John";`
B. `String name = John;`
C. `String name = "John`;`
D. `String name = "John"`
What does the `+` operator do when used with two strings?
A. Adds the values
B. Concatenates the strings
✔✔C. Concatenates the strings
D. Divides the strings
How would you declare a `double` variable in Java?
A. `double number = 3.14;`
✔✔B. `double number = 3.14;`
2
, C. `double number = 3;`
D. `double number = 3.0;`
What will `System.out.println();` output?
A. 2
✔✔B. 2
C. 2.5
D. Compilation error
How do you declare a boolean variable in Java?
A. `boolean flag = true;`
✔✔B. `boolean flag = true;`
C. `boolean flag = 0;`
D. `boolean flag = 1;`
Which keyword is used to create a constant in Java?
A. `constant`
✔✔B. `final`
3