Java Basic Programs for Beginners
Java Basic Programs for Beginners - Important Points
36. | Which of the following is a valid way to declare and initialize a character array in Java? |
---|
A. char[] arr = {'a', 'b', 'c'};
B. char[] arr = new char[]{'a', 'b', 'c'};
C. char[] arr = new char[3]{'a', 'b', 'c'};
D. char[] arr = new char[3]; arr[0] = 'a'; arr[1] = 'b'; arr[2] = 'c';
View Answer Discuss Work SpaceAnswer: option b
Explanation:
37. | 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 b
Explanation:
38. | Which of the following is a valid way to declare and initialize a two-dimensional integer array in Java? |
---|
A. int[][] arr = {{1, 2, 3}, {4, 5, 6}};
B. int[][] arr = new int[][]{{1, 2, 3}, {4, 5, 6}};
C. int[][] arr = new int[2][3]{{1, 2, 3}, {4, 5, 6}};
D. int[][] arr = new int[2][3]; arr[0] = {1, 2, 3}; arr[1] = {4, 5, 6};
View Answer Discuss Work SpaceAnswer: option b
Explanation:
39. | What is the output of the following program? public class Main { |
---|
A. HELLO, WORLD!
B. Hello, world!
C. hello, world!
D. hELLO, WORLD!
View Answer Discuss Work SpaceAnswer: option a
Explanation: