Skip to main content

Modern Programming Languages MCQs with Answers

Practice important Modern Programming Languages MCQs with answers and explanations.

Multiple Choice Questions

Q531: Which class type in Java has an object for each primitive type?
  • A: Wrapper classes
  • B: Interface classes
  • C: Abstract classes
  • D: Primitive classes
View Answer
A

Q532: What is the role of the `this` keyword in Java constructors?
  • A: To access the current object's fields
  • B: To call another constructor in the same class
  • C: To return the current object
  • D: To initialize the object
View Answer
A

Q533: In Java, which of the following is true about static methods?
  • A: They can access instance variables
  • B: They cannot access instance variables
  • C: They must have a return type
  • D: They can only be called from a subclass
View Answer
B

Q534: What is required to specify a package in a Java file?
  • A: package name
  • B: package declaration
  • C: package keyword
  • D: package statement
View Answer
A

Q535: Which keyword prevents a class from being extended in Java?
  • A: final
  • B: abstract
  • C: protected
  • D: private
View Answer
A

Q536: In Java, how can you access public classes in another package?
  • A: package-name.class-name
  • B: package-name.method-name
  • C: class-name.method-name
  • D: method-name.class-name
View Answer
A

Q537: What is the purpose of the 'import' statement in Java?
  • A: It allows access to non-public classes
  • B: It enables code optimization
  • C: It imports classes from another package
  • D: It imports classes into the main method
View Answer
C

Q538: Which method must be defined in a subclass to override a method in Java?
  • A: The constructor
  • B: The method with the same name
  • C: Any method
  • D: The method with different arguments
View Answer
B

Q539: What is the purpose of the 'final' keyword in Java?
  • A: It makes a method accessible from any class
  • B: It makes a method not overrideable
  • C: It allows inheritance
  • D: It prevents class instantiation
View Answer
B

Q540: What does inheritance in Java allow?
  • A: Access to private fields
  • B: Implementation of an interface
  • C: Sharing fields and methods between classes
  • D: Creation of abstract methods
View Answer
C

Test Your Knowledge

Take a timed quiz on Modern Programming Languages

🚀 Start Quiz Now