Modern Programming Languages MCQs with Answers
Practice important Modern Programming Languages MCQs with answers and explanations.
Chapter: 27
Q481:
Which of the following types does Java support for arrays?
A. Structs
B. Enums
C. Union
D. Reference types
Correct Answer:
D
Chapter: 27
Q482:
What is the maximum number of public classes allowed in a single Java source file?
A. None
B. One
C. Two
D. Multiple
Correct Answer:
B
Chapter: 27
Q483:
What file extension does the compiled Java code have?
A. .java
B. .class
C. .src
D. .exe
Correct Answer:
B
Chapter: 27
Q484:
What is the purpose of the System.arraycopy method in Java?
A. Copies data from one array to another
B. Sorts an array
C. Reverses an array
D. Fills an array with default values
Correct Answer:
A
Chapter: 27
Q485:
In Java, what happens if you try to access an array element out of bounds?
A. Runtime error
B. Compilation error
C. Program terminates successfully
D. None of the above
Correct Answer:
A
Chapter: 27
Q486:
In Java, which of the following types is used to declare a reference to an array?
A. int[] A
B. int A[]
C. int[]
D. A[]
Correct Answer:
A
Chapter: 27
Q487:
In Java, how do you determine the length of an array at runtime?
A. Using "length" operator
B. Using "size" method
C. Using "length()" method
D. Using "getSize" method
Correct Answer:
A
Chapter: 27
Q488:
Which of the following is true about arrays in Java?
A. All arrays are dynamically sized
B. Arrays can be multidimensional
C. Only one-dimensional arrays are supported
D. None of the above
Correct Answer:
B
Chapter: 27
Q489:
Which keyword is used to declare a constant in Java?
A. const
B. final
C. static
D. immutable
Correct Answer:
B
Chapter: 27
Q490:
What is the default value for a reference type variable in Java?
A. 1
B. null
C. undefined
Correct Answer:
B
Chapter: 27
Q491:
Which of the following is NOT a valid array declaration in Java?
A. int[] A = new int[5];
B. int A[] = new int[5];
C. int[5] A;
D. int[] A = {1, 2, 3};
Correct Answer:
C
Chapter: 27
Q492:
What is the correct way to declare a two-dimensional array in Java?
A. int[][] A;
B. int[] A[];
C. int[5][5] A;
D. Two-dimensional arrays are not allowed
Correct Answer:
A
Chapter: 27
Q493:
What is the purpose of the main function in Java?
A. To start the execution of a program
B. To perform calculations
C. To define global variables
D. To manage memory
Correct Answer:
A
Chapter: 27
Q494:
Java eliminates which of the following C++ features?
A. Multiple inheritance
B. Pointers
C. Structs
D. All of the above
Correct Answer:
D
Chapter: 27
Q495:
What type of data type is used for storing a single 16-bit Unicode character in Java?
A. byte
B. char
C. int
D. long
Correct Answer:
B
Chapter: 27
Q496:
What is the file extension for Java source code?
A. .java
B. .class
C. .js
D. .txt
Correct Answer:
A
Chapter: 27
Q497:
Which of the following is true about arrays in Java?
A. They are fixed size once declared
B. They can only store integers
C. They cannot be multidimensional
D. None of the above
Correct Answer:
A
Chapter: 27
Q498:
Which Java class method is used to output text to the console?
A. System.out.println
B. System.print()
C. Stream.out.println
D. Console.write()
Correct Answer:
A
Chapter: 27
Q499:
Which of the following is NOT allowed in a Java source file?
A. Multiple main functions
B. One public class
C. Multiple classes
D. Single class
Correct Answer:
B
Chapter: 27
Q500:
What will the statement "System.arraycopy(A, 0, B, 0, 5)" do in Java?
A. Copies 5 elements from array A to array B
B. Copies 5 elements from array B to array A
C. Sorts array A
D. Reverses array A
Correct Answer:
A