0% found this document useful (0 votes)
15 views9 pages

MCQ QUestions

Uploaded by

harbinkannan456
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views9 pages

MCQ QUestions

Uploaded by

harbinkannan456
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 9

Module 1

1. Object-Oriented Programming: What is the main concept behind Object-Oriented


Programming (OOP)?
o A. Functions
o B. Objects
o C. Procedures
o D. Variables
2. First Simple Program: In Java, what is the entry point for the execution of a program?
o A. main()
o B. start()
o C. execute()
o D. run()
3. Control Statements: Which control statement is used to execute a block of code
repeatedly as long as a given condition is true?
o A. if-else
o B. for
o C. switch
o D. while
4. Java Class Libraries: Which package provides classes for input and output operations in
Java?
o A. java.lang
o B. java.util
o C. java.io
o D. java.net
5. Data Types: What type of programming language is Java in terms of data typing?
o A. Dynamically Typed
o B. Weakly Typed
o C. Strongly Typed
o D. Statically Typed
6. Primitive Types: Which of the following is a primitive data type in Java?
o A. String
o B. Double
o C. Array
o D. Object
7. Integers: What is the size (in bits) of the int data type in Java?
o A. 8
o B. 16
o C. 32
o D. 64
8. Floating-Point Types: Which keyword is used to declare a floating-point variable in
Java?
o A. float
o B. double
o C. decimal
o D. real
9. Characters: In Java, what is the data type for representing a single character?
o A. char
o B. character
o C. single
o D. letter
10. A Closer Look at Literals: What is a literal in Java?
o A. A comment
o B. A value written directly in the code
o C. A method declaration
o D. An object reference
11. Type Conversion and Casting: What is the purpose of casting in Java?
o A. To convert between different data types
o B. To comment out code
o C. To create objects
o D. To declare variables
12. Arrays: How do you access an element at index 3 in an array named numbers?
o A. numbers[3]
o B. numbers{3}
o C. numbers.at(3)
o D. numbers.index(3)

1. B. Objects
2. A. main()
3. D. while
4. C. java.io
5. C. Strongly Typed
6. B. Double
7. C. 32
8. B. double
9. A. char
10. B. A value written directly in the code
11. A. To convert between different data types
12. A. numbers[3]

Module 2

1. Arithmetic Operators: What is the result of the expression 10 / 3 in Java?


o A. 3
o B. 3.33
o C. 3.0
o D. 3.5
2. Bitwise Operators: Which bitwise operator is used for shifting bits to the right?
o A. << (left shift)
o B. >> (right shift)
o C. & (AND)
o D. | (OR)
3. Relational Operators: What is the result of the expression 5 > 3?
o A. true
o B. false
o C. 2
o D. 8
4. Boolean Logical Operators: What is the logical AND operator in Java?
o A. &&
o B. ||
o C. !
o D. &
5. Assignment Operator: What is the purpose of the += operator in Java?
o A. Add and equal
o B. Multiply and assign
o C. Add and assign
o D. Divide and assign
6. ? Operator: What is the name of the ternary operator in Java?
o A. :?
o B. ?
o C. ::
o D. -:
7. Operator Precedence: In Java, which operator has the highest precedence?
o A. +
o B. *
o C. =
o D. /
8. Using Parentheses: What is the purpose of using parentheses in expressions?
o A. To indicate comments
o B. To group operations and control precedence
o C. To multiply values
o D. To assign values
9. Selection Statements: Which statement is used for making decisions in Java?
o A. for
o B. while
o C. if
o D. switch
10. Iteration Statements: What is the purpose of the for loop in Java?
o A. Iterating a block of code a specific number of times
o B. Making decisions
o C. Breaking out of loops
o D. Assigning values
11. Jump Statements: Which statement is used to immediately terminate a loop in Java?
o A. break
o B. continue
o C. return
o D. exit
12. Control Statements: What category of control statements does the switch statement
belong to?
o A. Iteration
o B. Selection
o C. Jump
o D. Loop

Answers:

1. C
2. B
3. A
4. A
5. C
6. B
7. B
8. B
9. C
10. A
11. A
12. B

Module 3

1. Declaring Objects: How is an object declared in Java?


o A. objectName = new ObjectType();
o B. new ObjectType() = objectName;
o C. ObjectType objectName;
o D. ObjectType objectName = new ObjectType();
2. Methods: What is a method in Java?
o A. A variable
o B. A class
o C. A function associated with an object
o D. A loop statement
3. Constructors: When is a constructor called in Java?
o A. Before a method
o B. After a method
o C. When an object is created
o D. When a variable is declared
4. this Keyword: What does the this keyword refer to in Java?
o A. Current class instance
o B. Previous class instance
o C. Next class instance
o D. Parent class instance
5. Garbage Collection: What is the purpose of garbage collection in Java?
o A. Allocating memory
o B. Releasing memory occupied by unreferenced objects
o C. Initializing objects
o D. Optimizing code execution
6. finalize() Method: When is the finalize() method called in Java?
o A. Before an object is created
o B. After an object is created
o C. Before an object is garbage collected
o D. After an object is garbage collected
7. A Closer Look at Methods and Classes: What is method overloading?
o A. Assigning multiple names to a method
o B. Defining multiple methods with the same name but different parameters
o C. Using a single method for all operations
o D. Using methods in different classes
8. Using Objects as Parameters: In Java, can objects be passed as parameters to methods?
o A. No, only primitive types can be passed
o B. Yes, objects can be passed
o C. Only arrays can be passed
o D. Objects can only be returned, not passed
9. Recursion: What is recursion in Java?
o A. A method with no return type
o B. A method calling itself
o C. A method returning multiple values
o D. A method with a static keyword
10. Introducing Access Control: What is the purpose of access control in Java?
o A. Restricting access to certain methods
o B. Enabling access to all methods
o C. Restricting access to all methods
o D. Enabling access to specific classes only
11. Understanding static: What is the significance of the static keyword in Java?
o A. It makes a variable non-modifiable
o B. It makes a variable accessible only within the class
o C. It makes a variable shared among all instances of the class
o D. It makes a variable constant
12. Introducing final: What does the final keyword signify in Java?
o A. The end of a method
o B. The end of a class
o C. The end of a variable
o D. The immutability of a variable
13. Arrays Revisited: How is an array declared in Java?
o A. int array[];
o B. array[] int;
o C. array int[];
o D. array[] = int;
14. Inheritance: What is inheritance in Java?
o A. Copying methods from one class to another
o B. Acquiring properties and behaviors of a parent class in a child class
o C. Declaring variables in multiple classes
o D. Hiding methods in a class
15. Using super: What is the purpose of the super keyword in Java?
o A. Calling the parent class constructor
o B. Calling the child class constructor
o C. Referencing the current class instance
o D. Referencing the parent class instance

Answers:

1. D
2. C
3. C
4. A
5. B
6. C
7. B
8. B
9. B
10. A
11. C
12. D
13. A
14. B
15. A

Module 4

1. Packages: What is the purpose of using packages in Java?


o A. To make the code shorter
o B. To organize classes and interfaces into namespaces
o C. To increase code readability
o D. To enforce encapsulation
2. Access Protection: Which access modifier restricts access the least in Java?
o A. private
o B. protected
o C. default (package-private)
o D. public
3. Importing Packages: How is a specific class imported in Java?
o A. import packageName.*;
o B. import packageName.ClassName;
o C. import ClassName from packageName;
o D. include packageName.ClassName;
4. Interfaces: In Java, can a class implement multiple interfaces?
o A. No, a class can implement only one interface
o B. Yes, a class can implement multiple interfaces
o C. Only abstract classes can implement interfaces
o D. Interfaces cannot be implemented by classes
5. Exception-Handling Fundamentals: What is the purpose of exception handling in Java?
o A. To hide errors from the compiler
o B. To terminate the program on encountering an error
o C. To gracefully handle errors and prevent program crashes
o D. To create intentional errors for testing
6. Using try and catch: In a try-catch block, where should the catch block be placed?
o A. Before the try block
o B. After the try block
o C. Inside the try block
o D. Inside the finally block
7. throw and throws: What is the purpose of the throw keyword in Java?
o A. To throw a custom exception
o B. To catch an exception
o C. To terminate the program
o D. To declare an exception
8. finally: In Java, when is the finally block executed?
o A. After the try block
o B. Before the try block
o C. Only if an exception is caught
o D. Always, whether an exception is caught or not
9. Java’s Built-in Exceptions: Which class is the superclass of all exception classes in
Java?
o A. RuntimeException
o B. Exception
o C. Error
o D. Throwable
10. Creating Your Own Exception Subclasses: Why might you create your own exception
subclass in Java?
o A. To override built-in exceptions
o B. To make the code shorter
o C. To handle specific exceptional conditions
o D. Exception subclasses are not allowed in Java

Answers:

1. B
2. D
3. B
4. B
5. C
6. B
7. A
8. D
9. D
10. C

Module 5

1. I/O Basics: What is the purpose of I/O in Java?


o A. To implement graphical user interfaces
o B. To manage input and output operations
o C. To perform mathematical calculations
o D. To handle exceptions
2. Reading Console Input: Which class is commonly used to read input from the console
in Java?
o A. Scanner
o B. BufferedReader
o C. InputStream
o D. Console
3. Writing Console Output: How is console output typically written in Java?
o A. System.console().write()
o B. System.out.print()
o C. System.in.write()
o D. Console.write()
4. PrintWriter Class: In Java, what is the role of the PrintWriter class?
o A. Reading files
o B. Writing formatted text to files
o C. Reading console input
o D. Writing binary data to files
5. Applet Fundamentals: What is an applet in Java?
o A. A small insect
o B. A small application designed to run on a web browser
o C. A command-line program
o D. A type of exception
6. Using transient and volatile Modifiers: What is the purpose of the transient modifier
in Java?
o A. It makes a variable volatile
o B. It indicates that a variable should not be serialized
o C. It makes a variable thread-safe
o D. It is used to declare native methods
7. Using instance of: What is the purpose of the instanceof operator in Java?
o A. It checks if an object is an instance of a particular class
o B. It converts an object to an instance of a class
o C. It checks if a class is abstract
o D. It checks if a class is final
8. strictfp: In Java, what does the strictfp keyword do?
o A. It enforces strict file path naming
o B. It ensures strict type checking
o C. It ensures strict floating-point precision
o D. It enforces strict exception handling
9. Native Methods: What is the role of native methods in Java?
o A. They are methods written in the Java programming language
o B. They are methods that can be overridden
o C. They are methods implemented in another programming language
o D. They are methods used for mathematical calculations
10. Using assert: How is the assert statement used in Java?
o A. To create custom exceptions
o B. To handle runtime errors
o C. To test assumptions about program state
o D. To import static methods

Answers:

1. B
2. A
3. B
4. B
5. B
6. B
7. A
8. C
9. C
10. C

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy