Skip to main content

Modern Programming Languages MCQs with Answers

Practice important Modern Programming Languages MCQs with answers and explanations.

Chapter: 27
Q501:
Java arrays are ________ compared to C++ arrays.
A. Dynamically sized
B. Fixed size
C. Immutable
D. Unchangeable
Correct Answer: B
Chapter: 27
Q502:
Fill in the blank: In Java, the storage for an array is allocated only when you use the _______ keyword.
A. new
B. allocate
C. create
D. build
Correct Answer: A
Chapter: 27
Q503:
Fill in the blank: The keyword used to declare constants in Java is _______.
A. final
B. static
C. const
D. immutable
Correct Answer: B
Chapter: 27
Q504:
Fill in the blank: The size of a Java array cannot be changed once it has been _______.
A. initialized
B. declared
C. created
D. allocated
Correct Answer: C
Chapter: 28
Q505:
What does a constructor function in Java do?
A. Initializes an instance of a class
B. Overloads methods
C. Creates an object of a class
D. Overrides a class method
Correct Answer: A
Chapter: 28
Q506:
Which of the following types cannot be implicitly converted to other primitive types in Java?
A. Booleans
B. Shorts
C. Longs
D. Floats
Correct Answer: A
Chapter: 28
Q507:
In Java, which type of conversion requires explicit casting?
A. Implicit conversion
B. Character conversion
C. Primitive type conversion
D. Overloading methods
Correct Answer: B
Chapter: 28
Q508:
Which of the following is a valid statement for defining a public method in Java?
A. public void methodName(){}
B. private void methodName(){}
C. protected void methodName(){}
D. void methodName(){}
Correct Answer: A
Chapter: 28
Q509:
In Java, all classes are implicitly subclasses of which class?
A. Object
B. Class
C. System
D. Package
Correct Answer: A
Chapter: 28
Q510:
What happens when you assign one array to another array in Java?
A. The arrays point to the same memory location
B. The arrays are copied element by element
C. A compile-time error occurs
D. A runtime exception occurs
Correct Answer: A
Chapter: 28
Q511:
In Java, what does the keyword `static` signify when applied to a field or method?
A. The field/method is only accessible within the class
B. The field/method belongs to the instance of the class
C. The field/method is shared across all instances of the class
D. The field/method is only accessible within its package
Correct Answer: C
Chapter: 28
Q512:
Which of the following is a valid Java class constructor declaration?
A. public MyClass(){}
B. private MyClass(){}
C. public MyClass(int x){}
D. private MyClass(int x){}
Correct Answer: A
Chapter: 28
Q513:
What is the purpose of the `final` keyword in Java?
A. To define a constant
B. To allow method overriding
C. To ensure a method is private
D. To make a field non-static
Correct Answer: A
Chapter: 28
Q514:
Which class type cannot be stored in a Java List?
A. Objects
B. Primitives
C. Any subclass of Object
D. Interfaces
Correct Answer: B
Chapter: 28
Q515:
Which method in Java is used to initialize a List class instance?
A. AddToEnd()
B. Constructor()
C. Initialize()
D. Reset()
Correct Answer: B
Chapter: 28
Q516:
In Java, a field with no specified access modifier has which access level?
A. Private
B. Public
C. Package
D. Protected
Correct Answer: C
Chapter: 28
Q517:
Which of the following types of variables in Java cannot be assigned a value after initialization?
A. Static variables
B. Final variables
C. Local variables
D. Instance variables
Correct Answer: B
Chapter: 28
Q518:
Which type of conversion is done implicitly in Java?
A. From long to int
B. From double to float
C. From byte to short
D. From char to int
Correct Answer: D
Chapter: 28
Q519:
In Java, what is the result of casting a floating-point value to an integer?
A. The value is truncated
B. The value is rounded
C. The value is multiplied by 2
D. The value is converted into binary
Correct Answer: A
Chapter: 28
Q520:
In Java, which of the following allows you to store any type of object in a List?
A. Primitive types
B. Interfaces
C. Objects
D. Generics
Correct Answer: C

Test Your Knowledge

Take a timed quiz on Modern Programming Languages

🚀 Start Quiz Now