0% found this document useful (0 votes)
3 views

java MCQ's

The document contains a series of questions and answers related to Object-Oriented Programming (OOP), Java programming constructs, and exception handling. It covers fundamental concepts such as OOP principles, Java syntax, data types, control structures, interfaces, and error handling mechanisms. Each section includes multiple-choice questions that test knowledge on these topics.

Uploaded by

hiibye0002
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

java MCQ's

The document contains a series of questions and answers related to Object-Oriented Programming (OOP), Java programming constructs, and exception handling. It covers fundamental concepts such as OOP principles, Java syntax, data types, control structures, interfaces, and error handling mechanisms. Each section includes multiple-choice questions that test knowledge on these topics.

Uploaded by

hiibye0002
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 13

UNIT I: Introduction to OOPS

1. Which programming concept is based on objects and classes?


A) Procedural Programming
B) Functional Programming
C) Object-Oriented Programming
D) Modular Programming

2. Which language is known as the first OOP language?


A) C++
B) Java
C) Smalltalk
D) Python

3. What is the full form of OOPS?


A) Object-Oriented Programming System
B) Object Open Programming Structure
C) Object Oriented Procedural System
D) None

4. Which concept binds data and methods together?


A) Inheritance
B) Encapsulation
C) Polymorphism
D) Abstraction

5. What is Java Virtual Machine (JVM)?


A) Hardware
B) Interpreter
C) Compiler
D) Emulator

6. Which keyword is used to create an object in Java?


A) new
B) class
C) object
D) method

7. Which feature allows reusing of code in Java?


A) Encapsulation
B) Polymorphism
C) Inheritance
D) Abstraction
8. Which concept provides multiple forms to a single function?
A) Polymorphism
B) Abstraction
C) Encapsulation
D) Inheritance

9. What is the purpose of Java packages?


A) To import classes
B) To group related classes
C) To define variables
D) None

10. Which is a procedural programming language?


A) Java
B) C++
C) C
D) Python

11. What is the file extension of a compiled Java file?


A) .java
B) .class
C) .exe
D) .jar

12. Which is not an application of OOPS?


A) Web Development
B) Operating System Development
C) Game Development
D) Simple Calculator

13. Which feature hides complexity from users?


A) Encapsulation
B) Abstraction
C) Polymorphism
D) Inheritance

14. Which version of JDK is mentioned for installation?


A) JDK 14
B) JDK 15
C) JDK 16
D) JDK 17
15. Java source code is first compiled into:
A) Machine Code
B) Bytecode
C) Binary Code
D) Intermediate Code

16. Who developed Java?


A) Microsoft
B) Sun Microsystems
C) IBM
D) Oracle

17. Java programs are platform-_________.


A) Dependent
B) Independent
C) Semi-dependent
D) None

18. OOPS stands for:


A) Object Oriented Programming Software
B) Object Oriented Programming Structure
C) Object Oriented Programming System
D) Object Operating Programming Structure

19. Which concept focuses on exposing only necessary details?


A) Inheritance
B) Encapsulation
C) Abstraction
D) Polymorphism

20. Which method is the entry point for a Java program?


A) start()
B) main()
C) execute()
D) run()
UNIT II: Programming Constructs
1. Which keyword is used to define a variable in Java?
A) var
B) int
C) define
D) new

2. Which of the following is a primitive data type?


A) String
B) Array
C) int
D) Class

3. Which of these is not a valid identifier?


A) myVariable
B) 1variable
C) _variable
D) variable1

4. Which is used for naming conventions in Java?


A) CamelCase
B) snake_case
C) kebab-case
D) PascalCase

5. Which operator is used for addition in Java?


A) +
B) -
C) *
D) /

6. Which operator is used for logical AND?


A) &
B) &&
C) ||
D) !

7. What will be the result of 5 + 3 * 2?


A) 16
B) 11
C) 10
D) 13

8. Which conversion happens automatically in Java?


A) Widening Conversion
B) Narrowing Conversion
C) Explicit Conversion
D) None

9. Casting double to int is called:


A) Widening
B) Promotion
C) Casting
D) Type Conversion

10. Which type of array stores similar data types?


A) Homogeneous
B) Heterogeneous
C) Primitive
D) Composite

11. Which statement is used for conditional branching?


A) switch
B) for
C) do-while
D) try-catch

12. Which control statement is used to loop through a block?


A) if
B) for
C) break
D) switch

13. Which operator has the highest precedence?


A) +
B) *
C) ()
D) &&

14. What is the keyword to exit from a loop?


A) exit
B) continue
C) break
D) return
15. Which loop checks the condition at the end?
A) while
B) for
C) do-while
D) if

16. Command-line arguments are passed to the program through:


A) args[]
B) strings[]
C) var[]
D) main[]

17. Which of the following is a binary operator?


A) +
B) -
C) *
D) All

18. Which of these is not a primitive data type?


A) float
B) boolean
C) object
D) char

19. What will be the value of ‘result’ if a=5, b=3 in ‘result = a % b’?
A) 1
B) 2
C) 0
D) 5

20. What is the default value of an int variable in Java?


A) 0
B) 1
C) -1
D) null

21. Which control structure executes a block multiple times?


A) Loop
B) if
C) switch
D) continue
22. Which loop is used when the number of iterations is known?
A) while
B) for
C) do-while
D) if

23. Which operator is used for bitwise OR operation?


A) ||
B) |
C) &&
D) &

24. Which function is used to read command-line arguments?


A) Scanner
B) InputStream
C) args[]
D) Reader

25. Which expression is evaluated first based on precedence?


A) *, /
B) +, -
C) &&
D) ||

26. Which literal represents a character constant?


A) "A"
B) 'A'
C) A
D) 'AB'

27. Which flow control statement is used to skip current iteration?


A) break
B) continue
C) return
D) switch
28. Which one is used for branching based on multiple conditions?
A) if-else
B) for
C) switch
D) while

29. Which of these cannot be a keyword in Java?


A) static
B) main
C) try
D) class

30. Which operator is used for equality checking?


A) =
B) ==
C) !=
D) ===
UNIT III: Interface and Exceptions
1. Which keyword is used to implement an interface?
A) inherit
B) implements
C) extends
D) interface

2. An interface can contain which type of methods?


A) Final
B) Abstract
C) Static only
D) Concrete

3. What keyword is used to create an interface?


A) class
B) interface
C) implements
D) package

4. Which of the following is true about interfaces?


A) Can contain constructors
B) Cannot have constructors
C) Can instantiate directly
D) None

5. How many classes can implement an interface?


A) Only one
B) Two
C) Many
D) None

6. What is the default access modifier for interface methods?


A) public
B) private
C) protected
D) default

7. Which is a keyword used to access a package in Java?


A) include
B) import
C) package
D) export

8. Which Java keyword is used to create a package?


A) package
B) import
C) class
D) interface

9. Which exception is thrown when a program accesses a null object?


A) NullPointerException
B) ArrayIndexOutOfBoundsException
C) IOException
D) NumberFormatException

10. Which package contains exception classes?


A) java.util
B) java.io
C) java.lang
D) java.net

11. Which keyword is used to manually throw an exception?


A) throws
B) throw
C) catch
D) try

12. Which block is always executed in exception handling?


A) try
B) catch
C) finally
D) throw

13. An interface can extend:


A) A class
B) Another interface
C) Both
D) None

14. What is used for error handling in Java?


A) if-else
B) try-catch
C) loops
D) switch

15. Which exception must be handled during compilation?


A) RuntimeException
B) CheckedException
C) Error
D) Throwable

16. What is encapsulation?


A) Hiding data
B) Inheriting classes
C) Overloading methods
D) None

17. Which access specifier is used for inheritance?


A) public
B) private
C) protected
D) final

18. What is an abstract class?


A) Class with complete implementation
B) Class with no methods
C) Class with incomplete implementation
D) Interface

19. Which of the following supports multiple inheritance?


A) Class
B) Abstract class
C) Interface
D) Enum
20. What happens if an exception is not caught?
A) Program continues
B) Program terminates
C) Program restarts
D) None

21. Which exception occurs during division by zero?


A) ArithmeticException
B) IOException
C) ArrayIndexOutOfBoundsException
D) NullPointerException

22. Which of the following is a runtime exception?


A) IOException
B) SQLException
C) ArithmeticException
D) FileNotFoundException

23. Which block is mandatory in exception handling?


A) try
B) catch
C) finally
D) None

24. Which technique is used for error prevention?


A) Exception Handling
B) Abstraction
C) Inheritance
D) Overriding

25. Which is a user-defined exception?


A) Exception created by user
B) Predefined exception
C) Built-in exception
D) None

26. What does throws keyword do?


A) Catches an exception
B) Declares an exception
C) Ignores an exception
D) Handles an exception

27. Which method must an interface class implement?


A) All methods
B) Only main()
C) Any two methods
D) None

28. How many interfaces can a class implement?


A) Only one
B) Multiple
C) Two
D) None

29. Which of these is NOT an access modifier?


A) public
B) private
C) default
D) static

30. Which method is used to read data from command line?


A) System.in.read()
B) System.read()
C) System.scan()
D) System.input()

You might also like