← Back to Subject
OOP Using Java • MCQ • Basic of Java Programming
Most Important 30 Objective Question - Basic of Java Programming
Q1. Java was developed by which company?
A) Microsoft
B) Sun Microsystems
C) Google
D) IBM

Answer: B) Sun Microsystems
Explanation: Java was developed by Sun Microsystems in 1995 under the leadership of James Gosling. Later, Sun Microsystems was acquired by Oracle Corporation.

Q2. Who is known as the father of Java?
A) Dennis Ritchie
B) Bjarne Stroustrup
C) James Gosling
D) Guido van Rossum

Answer: C) James Gosling
Explanation:James Gosling is called the Father of Java because he led the development of the Java language.

Q3. Which of the following is not a Java feature?
A) Platform Independent
B) Object-Oriented
C) Use of pointers
D) Secure

Answer: C) Use of pointers
Explanation:Java does not support explicit pointers because they create security problems and make programming complex.

Q4. Java source code file extension is:
A) .class
B) .java
C) .exe
D) .js

Answer: B) .java
Explanation:Java programs are written in files having the .java extension.

Q5. Compiled Java bytecode file extension is:
A) .java
B) .class
C) .exe
D) .txt

Answer: B) .class
Explanation:After compilation, Java source code converts into bytecode, stored in a .class file.

Q6. Which component executes Java bytecode?
A) JDK
B) JVM
C) JRE
D) Compiler

Answer: B) JVM
Explanation:The Java Virtual Machine (JVM) executes Java bytecode and makes Java platform independent.

Q7. JDK stands for:
A) Java Deployment Kit
B) Java Development Kit
C) Java Debug Kit
D) Java Document Kit

Answer: B) Java Development Kit
Explanation:JDK provides tools like compiler, debugger, and JRE for Java program development.

Q8. JRE stands for:
A) Java Runtime Environment
B) Java Read Environment
C) Java Run Engine
D) Java Real Environment

Answer: A) Java Runtime Environment
Explanation:JRE provides libraries and JVM required to run Java applications.

Q9. Which statement is used for output in Java?
A) print()
B) cout
C) System.out.println()
D) printf()

Answer: C) System.out.println()
Explanation:Java uses System.out.println() to display output on the screen.

Q10. Which data type is used for decimal values?
A) int
B) char
C) float
D) boolean

Answer: C) float
Explanation:Decimal numbers like 10.5, 25.75 are stored using float or double.

Q11. Which keyword is used to define a class in Java?
A) structure
B) class
C) object
D) define

Answer: B) class
Explanation:The keyword class is used to create a class in Java.
Example:
class Student
{
}

Q12. Which operator is used for comparison?
A) =
B) ==
C) :=
D) !=

Answer: B) ==
Explanation:The == operator is used to compare two values.
Example:
if(a == b)

Q13. Which loop executes at least once?
A) for
B) while
C) do-while
D) switch

Answer: C) do-while
Explanation:The do-while loop executes first and checks condition later, so it runs at least once.

Q14. Which control statement is used for multiple selection?
A) if
B) switch
C) while
D) break

Answer: B) switch
Explanation:The switch statement is used when multiple conditions are checked.

Q15. Java is which type of programming language?
A) Procedural only
B) Object-Oriented
C) Machine language
D) Assembly language

Answer: B) Object-Oriented
Explanation:Java mainly follows the Object-Oriented Programming (OOP) paradigm using classes and objects.

Q16. Which of the following is not an OOP feature?
A) Inheritance
B) Encapsulation
C) Polymorphism
D) Assembler

Answer: D) Assembler
Explanation:OOP features include Encapsulation, Inheritance, Polymorphism, and Abstraction.
Assembler is not an OOP feature.

Q17. Which feature of OOP hides data from direct access?
A) Inheritance
B) Encapsulation
C) Polymorphism
D) Overloading

Answer: B) Encapsulation
Explanation:Encapsulation wraps data and methods together and restricts direct access using access modifiers like private.

Q18. Which feature allows one class to acquire properties of another class?
A) Polymorphism
B) Inheritance
C) Abstraction
D) Interface

Answer: B) Inheritance
Explanation:Inheritance helps one class (child) use properties and methods of another class (parent).

Q19. Which OOP concept means “many forms”?
A) Encapsulation
B) Abstraction
C) Polymorphism
D) Inheritance

Answer: C) Polymorphism
Explanation:Polymorphism means one task performed in many ways, like method overloading and method overriding.

Q20. Which symbol is used for single-line comments in Java?
A)
B) //
C) /* */
D) #

Answer: B) //
Explanation:Single-line comments start with //
Example:
// This is a comment

Q21. Which symbol is used for multi-line comments?
A) //
B)
C) /* */
D) ##

Answer: C)
Explanation:Multi-line comments are written using / comment /
Example:
/* This is
multi-line comment */

Q22. Which keyword is used to import a package in Java?
A) include
B) import
C) package
D) using

Answer: B) import
Explanation:The import keyword is used to include predefined packages.
Example:
import java.util.Scanner;

Q23. Which keyword is used to create an object?
A) class
B) object
C) new
D) create

Answer: C) new
Explanation:The new keyword is used to allocate memory and create objects.
Example:
Student s = new Student();

Q24. Which method is the starting point of Java program execution?
A) start()
B) run()
C) main()
D) init()

Answer: C) main()
Explanation:Execution starts from the main() method.
Example:
public static void main(String[] args)

Q25. Which access specifier is most restrictive?
A) public
B) protected
C) private
D) default

Answer: C) private
Explanation:private members can only be accessed within the same class.

Q26. Which keyword is used for decision making?
A) if
B) loop
C) class
D) package

Answer: A) if
Explanation:The if statement is used for checking conditions and making decisions.

Q27. Which operator is used for logical AND?
A) &
B) &&
C) ||
D) !

Answer: B) &&
Explanation:The && operator returns true only if both conditions are true.

Q28. Which operator is used for logical OR?
A) &&
B) ||
C) !=
D) ++

Answer: B) ||
Explanation:The || operator returns true if at least one condition is true.

Q29. Which keyword is used to stop a loop?
A) continue
B) stop
C) break
D) exit

Answer: C) break
Explanation:The break statement immediately terminates the loop.

Q30. Which statement skips the current iteration of a loop?
A) break
B) continue
C) skip
D) return

Answer: B) continue
Explanation:The continue statement skips the current iteration and moves to the next one.
Google AdSense Ad Placement Here 📢