Modern Programming Languages MCQs with Answers
Practice important Modern Programming Languages MCQs with answers and explanations.
Multiple Choice Questions
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
View Answer
C
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){}
View Answer
A
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
View Answer
A
Q514: Which class type cannot be stored in a Java List?
- A: Objects
- B: Primitives
- C: Any subclass of Object
- D: Interfaces
View Answer
B
Q515: Which method in Java is used to initialize a List class instance?
- A: AddToEnd()
- B: Constructor()
- C: Initialize()
- D: Reset()
View Answer
B
Q516: In Java, a field with no specified access modifier has which access level?
- A: Private
- B: Public
- C: Package
- D: Protected
View Answer
C
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
View Answer
B
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
View Answer
D
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
View Answer
A
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
View Answer
C