Java Programming

Java is a high-level, object-oriented programming language developed by Sun Microsystems in the mid-1990s. It adheres to the “Write Once, Run Anywhere” (WORA) principle, ensuring platform independence via the Java Virtual Machine (JVM).

Java is a widely used programming language for coding web applications. It has been a popular choice among developers for over two decades, with millions of Java applications in use today. Java is a multi-platform, object-oriented, and network-centric language that can be used as a platform in itself. It is a fast, secure, reliable programming language for coding everything from mobile apps and enterprise software to big data applications and server-side technologies.

Which of the following is true about encapsulation in Java?

Java MCQ: Which of the following is true about encapsulation in Java? a) Encapsulation allows internal implementation to be hidden from the user b) Encapsulation is achieved using access modifiers c) Encapsulation makes code more flexible and maintainable d) All of the above Answer: d) All of the above Explanation: Encapsulation in Java is the […]

Which of the following is true about encapsulation in Java? Read More »

Which of the following statements about Java constructors is true?

Java MCQ: Which of the following statements about Java constructors is true? a) Constructors must have a return type b) Constructors can be abstract c) Constructors cannot be synchronized d) Constructors do not have a return type Answer: d) Constructors do not have a return type Explanation: Constructors in Java are special methods used to

Which of the following statements about Java constructors is true? Read More »

Which of the following is not a feature of Java?

Java MCQ: Which of the following is not a feature of Java? a) Dynamic b) Platform-independent c) Machine-dependent d) Multithreaded Answer: c) Machine-dependent Explanation: Java is designed to be platform-independent, meaning that Java programs can run on any device or operating system that has the Java Virtual Machine (JVM) installed. This “write once, run anywhere”

Which of the following is not a feature of Java? Read More »

Which of the following is not a valid access modifier in Java?

Java MCQ: Which of the following is not a valid access modifier in Java? a) private b) protected c) public d) internal Answer: d) internal Explanation: In Java, the valid access modifiers are private, protected, and public. These modifiers control the visibility of classes, methods, and variables. private makes a member accessible only within the

Which of the following is not a valid access modifier in Java? Read More »

Which of the following best describes method overloading in Java?

Java MCQ: Which of the following best describes method overloading in Java? a) Method overloading occurs when two methods in the same class have the same name but different parameter lists b) Method overloading is the process of overriding a method in a subclass c) Method overloading refers to the runtime resolution of method calls

Which of the following best describes method overloading in Java? Read More »

Which of the following is a characteristic of the ‘transient’ keyword in Java?

Java MCQ: Which of the following is a characteristic of the ‘transient’ keyword in Java? a) It prevents serialization of the variable b) It ensures that the variable is serialized c) It allows the variable to be accessed from any thread d) It makes the variable immutable Answer: a) It prevents serialization of the variable

Which of the following is a characteristic of the ‘transient’ keyword in Java? Read More »

Which of the following is true about the ‘static’ keyword in Java?

Java MCQ: Which of the following is true about the ‘static’ keyword in Java? a) Static methods belong to the class, not instances b) Static methods can access instance variables directly c) Static methods can be abstract d) Static methods can override instance methods Answer: a) Static methods belong to the class, not instances Explanation:

Which of the following is true about the ‘static’ keyword in Java? Read More »

Which of the following is true about inheritance in Java?

Java MCQ: Which of the following is true about inheritance in Java? a) Inheritance allows a class to inherit fields and methods from another class b) Java supports multiple inheritance through classes c) Inheritance is implemented using the ‘implements’ keyword d) Inheritance prevents method overriding Answer: a) Inheritance allows a class to inherit fields and

Which of the following is true about inheritance in Java? Read More »

Which of the following is not a valid access modifier in Java?

Java MCQ: Which of the following is not a valid access modifier in Java? a) private b) protected c) public d) internal Answer: d) internal Explanation: In Java, the valid access modifiers are private, protected, and public. These modifiers control the visibility of classes, methods, and variables. private makes a member accessible only within the

Which of the following is not a valid access modifier in Java? Read More »

Which of the following is a characteristic of the ‘transient’ keyword in Java?

Java MCQ: Which of the following is a characteristic of the ‘transient’ keyword in Java? a) It prevents serialization of the variable b) It ensures that the variable is serialized c) It allows the variable to be accessed from any thread d) It makes the variable immutable Answer: a) It prevents serialization of the variable

Which of the following is a characteristic of the ‘transient’ keyword in Java? Read More »

Which of the following statements is true about the ‘abstract’ keyword in Java?

Java MCQ: Which of the following statements is true about the ‘abstract’ keyword in Java? a) An abstract class cannot be instantiated b) Abstract methods do not have a body c) A class must be declared abstract if it contains abstract methods d) All of the above Answer: d) All of the above Explanation: The

Which of the following statements is true about the ‘abstract’ keyword in Java? Read More »

Which of the following statements about interfaces in Java is true?

Java MCQ: Which of the following statements about interfaces in Java is true? a) An interface can have instance variables b) An interface can extend multiple interfaces c) An interface can implement another interface d) An interface can have a constructor Answer: b) An interface can extend multiple interfaces Explanation: In Java, an interface can

Which of the following statements about interfaces in Java is true? Read More »

Which of the following best describes method overloading in Java?

Java MCQ: Which of the following best describes method overloading in Java? a) Method overloading occurs when two methods in the same class have the same name but different parameter lists b) Method overloading is the process of overriding a method in a subclass c) Method overloading refers to the runtime resolution of method calls

Which of the following best describes method overloading in Java? Read More »

Scroll to Top