Skip to main content

Modern Programming Languages MCQs with Answers

Practice important Modern Programming Languages MCQs with answers and explanations.

Chapter: 29
Q541:
Which of the following cannot be instantiated in Java?
A. Abstract class
B. Concrete class
C. Interface
D. Package
Correct Answer: A
Chapter: 29
Q542:
What does the 'extends' keyword signify in Java?
A. It creates a subclass
B. It makes a method final
C. It allows multiple inheritance
D. It imports methods from other packages
Correct Answer: A
Chapter: 29
Q543:
Which of the following is true about abstract methods in Java?
A. They must have a method body
B. They are defined in abstract classes
C. They can be implemented in any class
D. They can only be used in interfaces
Correct Answer: B
Chapter: 29
Q544:
What is the main difference between an interface and a class in Java?
A. An interface can have fields and methods
B. A class can only have methods
C. An interface can have only abstract methods
D. An interface has no constructors
Correct Answer: C
Chapter: 29
Q545:
Which of the following is true about interfaces in Java?
A. An interface cannot have constructors
B. An interface can have both instance and static methods
C. An interface can have a constructor but not methods
D. An interface can be instantiated
Correct Answer: A
Chapter: 29
Q546:
What is the purpose of the 'throws' clause in a method declaration?
A. It declares that a method can throw exceptions
B. It declares the method's return type
C. It defines the method's parameters
D. It handles exceptions
Correct Answer: A
Chapter: 29
Q547:
Which of the following is true about exception handling in Java?
A. Exceptions are only handled during runtime
B. Every catch block must specify an exception class
C. Exceptions are never thrown by JVM
D. Only checked exceptions need to be handled
Correct Answer: B
Chapter: 29
Q548:
Which of the following is an unchecked exception in Java?
A. NullPointerException
B. IOException
C. SQLException
D. InterruptedException
Correct Answer: A
Chapter: 29
Q549:
What is the difference between checked and unchecked exceptions in Java?
A. Checked exceptions are not related to JVM errors
B. Unchecked exceptions must be caught in a try block
C. Checked exceptions are caught only in runtime
D. Unchecked exceptions do not require handling by the compiler
Correct Answer: A
Chapter: 29
Q550:
What is the significance of the 'finally' block in Java exception handling?
A. It is executed only if no exception occurs
B. It is executed only if an exception occurs
C. It is always executed after the try block
D. It is used to declare exceptions
Correct Answer: C
Chapter: 29
Q551:
Which of the following exceptions is automatically thrown by the JVM in case of an out-of-bounds error?
A. RuntimeException
B. Error
C. IOException
D. Exception
Correct Answer: B
Chapter: 29
Q552:
Which of the following is NOT a valid reason to use the 'throws' clause in Java?
A. To declare that a method can throw checked exceptions
B. To declare that a method will handle exceptions
C. To allow exceptions to propagate to the caller
D. To specify the exceptions that a method can throw
Correct Answer: B
Chapter: 29
Q553:
What is true about multiple inheritance in Java?
A. Java supports multiple inheritance via classes
B. Multiple inheritance can only be achieved using interfaces
C. Java allows classes to implement only one interface
D. Multiple inheritance is not supported in Java classes
Correct Answer: B
Chapter: 29
Q554:
What happens if a subclass does not define the body for an abstract method?
A. The subclass will be abstract
B. The subclass will be instantiated
C. The abstract method will be skipped
D. The superclass method will be inherited
Correct Answer: A
Chapter: 29
Q555:
Which of the following is a characteristic of public methods in Java?
A. They are accessible only within the same class
B. They must have a method body
C. They can be overridden in a subclass
D. They are only accessible in the same package
Correct Answer: C
Chapter: 29
Q556:
What is the role of the 'super' keyword in Java constructors?
A. It calls the constructor of a subclass
B. It invokes a method of the superclass
C. It is used to access superclass fields
D. It is used to call the superclass constructor
Correct Answer: D
Chapter: 29
Q557:
What happens if a method is defined as 'final' in a superclass?
A. The method cannot be inherited
B. The method cannot be overridden
C. The method cannot be accessed
D. The method cannot be executed
Correct Answer: B
Chapter: 29
Q558:
Which keyword is used to prevent a method from being overridden in Java?
A. static
B. final
C. abstract
D. private
Correct Answer: B
Chapter: 29
Q559:
What happens if a 'final' class is extended in Java?
A. Compilation error occurs
B. The subclass inherits all methods from the final class
C. The final class can be instantiated
D. Only final methods can be inherited
Correct Answer: A
Chapter: 29
Q560:
Which class type can contain only method signatures but no method bodies?
A. Abstract class
B. Interface
C. Final class
D. Concrete class
Correct Answer: B

Test Your Knowledge

Take a timed quiz on Modern Programming Languages

🚀 Start Quiz Now