Java Basic Programs for Beginners
Java Basic Programs for Beginners - Important Points
| 31. | What is the output of the following program? public class Main { |
|---|
A. Hello
B. world
C. Hello,
D. , wor
View Answer Discuss Work SpaceAnswer: option b
Explanation:
| 32. | Which of the following is a valid way to declare and initialize a double variable in Java? |
|---|
A. double var = 3.14159;
B. double var = 3,14159;
C. double var = "3.14159";
D. double var = Double.parseDouble("3.14159");
View Answer Discuss Work SpaceAnswer: option a
Explanation:
| 33. | What is the output of the following program? public class Main { |
|---|
A. 2.5
B. 2
C. 3
D. 1
View Answer Discuss Work SpaceAnswer: option d
Explanation:
| 34. | Which of the following is not a valid way to declare and initialize a boolean array in Java? |
|---|
A. boolean[] arr = {true, false, true};
B. boolean[] arr = new boolean[]{true, false, true};
C. boolean[] arr = new boolean[3] {true, false, true};
D. boolean[] arr = new boolean[3]; arr[0] = true; arr[1] = false; arr[2] = true;
View Answer Discuss Work SpaceAnswer: option c
Explanation:
| 35. | What is the output of the following program? public class Main { |
|---|
A. 10
B. 11
C. 12
D. Compilation error
View Answer Discuss Work SpaceAnswer: option b
Explanation: