Q1. What is Java?
a) A type of coffee
b) A programming language
c) An operating system
d) A brand of clothing
b) A programming language
a) It is a purely procedural language
b) It can only be used for web development
c) It is platform-independent
d) It is a low-level language
c) It is platform-independent
a) A template for creating objects
b) A built-in data type
c) A loop structure
d) A file extension
a) A template for creating objects
a) instance
b) object
c) new
d) create
c) new
a) It indicates that a method is only accessible within the same class
b) It indicates that a method can be called on a class itself, rather than on an instance of the class
c) It indicates that a method is deprecated
d) It indicates that a method is synchronized
b) It indicates that a method can be called on a class itself, rather than on an instance of the class
a) float
b) double
c) int
d) char
c) int
a) 0
b) null
c) false
d) The value depends on the data type
b) null
a) public
b) protected
c) default (no modifier)
d) private
d) private
a) A type of class that cannot be instantiated
b) A collection of static methods
c) A way to achieve multiple inheritance in Java
d) A design pattern for creating objects
a) A type of class that cannot be instantiated
a) parent
b) base
c) super
d) this
c) super
a) It refers to the current instance of the class
b) It creates a new object
c) It is used to call a superclass method
d) It is used to declare variables
a) It refers to the current instance of the class
a) for loop
b) while loop
c) do-while loop
d) infinite loop
c) do-while loop
a) It terminates the entire program
b) It exits the current loop or switch statement
c) It continues to the next iteration of a loop
d) It skips a block of code
b) It exits the current loop or switch statement
a) try
b) catch
c) throw
d) all of the above
d) all of the above
a) It is used to define a block of code that is always executed
b) It is used to handle exceptions
c) It is used to define a block of code that is executed if an exception is thrown
d) It is used to define a block of code that is only executed when no exception occurs
a) It is used to define a block of code that is always executed
a) Writing multiple methods with the same name but different parameters
b) Writing methods with different names but the same parameters
c) Writing methods that perform the same operation
d) Writing methods with the same name and parameters, but in different classes
a) Writing multiple methods with the same name but different parameters
a) Writing methods with different names but the same parameters
b) Writing methods that perform the same operation
c) Writing methods with the same name and parameters, but in different classes
d) Writing methods in the same class with the same name and parameters as a superclass method
d) Writing methods in the same class with the same name and parameters as a superclass method
a) A method that returns a value
b) A special method used to create objects
c) A method that is static
d) A method that cannot be overridden
b) A special method used to create objects
a) It is used to check if an object is null
b) It is used to create a new instance of a class
c) It is used to check if an object is an instance of a particular class or interface
d) It is used to compare two objects for equality
c) It is used to check if an object is an instance of a particular class or interface
a) There is no difference; both operators are used interchangeably
b) '==' compares the content of the objects, while '.equals()' compares the memory addresses
c) '.equals()' compares the content of the objects, while '==' compares the memory addresses
d) '.equals()' is used for primitive data types, while '==' is used for objects
c) '.equals()' compares the content of the objects, while '==' compares the memory addresses
a) A physical computer
b) A virtual operating system
c) A compiler
d) An environment that executes Java bytecode
d) An environment that executes Java bytecode
a) Each instance of the class has its own copy of the field
b) The field belongs to the class itself, not to instances of the class
c) The field cannot be accessed outside the class
d) The field cannot be modified after it is initialized
b) The field belongs to the class itself, not to instances of the class
a) It indicates that a class cannot be inherited
b) It indicates that a method cannot be overridden
c) It indicates that a variable cannot be modified after initialization
d) It indicates that a variable is automatically initialized
c) It indicates that a variable cannot be modified after initialization
a) A collection of classes and interfaces
b) A set of predefined classes
c) A type of data structure
d) A file that contains Java code
a) A collection of classes and interfaces
a) sealed
b) closed
c) final
d) locked
c) final
a) The process of converting a primitive data type to an object of its corresponding wrapper class
b) The process of converting an object to a primitive data type
c) The process of converting between different data types
d) The process of converting a character to its ASCII value
a) The process of converting a primitive data type to an object of its corresponding wrapper class
a) It is used to build graphical user interfaces
b) It is used to manipulate strings efficiently
c) It is used to perform mathematical calculations
d) It is used to handle exceptions in Java
b) It is used to manipulate strings efficiently
a) A set of predefined collections in Java
b) A framework for creating graphical user interfaces
c) A library for managing networking in Java
d) A framework for working with data structures and algorithms related to collections
d) A framework for working with data structures and algorithms related to collections
a) List
b) Set
c) Map
d) Collection
b) Set
a) Thread
b) Runnable
c) Executor
d) Concurrency
a) Thread
a) The process of converting a synchronized block to an unsynchronized block
b) The process of making methods asynchronous
c) The process of preventing multiple threads from accessing shared resources simultaneously
d) The process of converting asynchronous methods to synchronous methods
c) The process of preventing multiple threads from accessing shared resources simultaneously
a) array
b) new
c) create
d) make
b) new
a) 1
b) 2
c) 3
d) There is no limit
d) There is no limit
a) A method that cannot be called on a class
b) A method that belongs to the class, not to instances of the class
c) A method that cannot be overridden
d) A method that cannot be used in a constructor
b) A method that belongs to the class, not to instances of the class
a) It is used to make a variable constant
b) It is used to prevent a variable from being modified
c) It is used to indicate that a variable should not be serialized
d) It is used to indicate that a variable is thread-safe
c) It is used to indicate that a variable should not be serialized
a) It is used to declare variables with a fixed value
b) It is used to indicate that a variable can be modified by multiple threads
c) It is used to define constant variables
d) It is used to indicate that a variable cannot be modified after initialization
b) It is used to indicate that a variable can be modified by multiple threads
a) An anonymous inner class
b) A named function
c) A type of exception
d) A concise way to represent an instance of a functional interface using a compact syntax
d) A concise way to represent an instance of a functional interface using a compact syntax
a) It specifies the default value for a variable
b) It specifies the default action to take if none of the cases match
c) It specifies the default visibility for a class
d) It specifies the default behavior of a loop
b) It specifies the default action to take if none of the cases match
a) It indicates that a method is throwing an exception
b) It indicates that a method is catching an exception
c) It indicates that a method is returning a value
d) It indicates that a method is asynchronous
a) It indicates that a method is throwing an exception
a) A collection of threads with the same priority
b) A group of threads that share the same stack memory
c) A collection of pre-initialized thread objects that are used to execute tasks concurrently
d) A set of threads that are locked to a specific processor core
c) A collection of pre-initialized thread objects that are used to execute tasks concurrently
a) It is used to define constants
b) It is used to check if an expression is true; if false, it throws an AssertionError
c) It is used to terminate the program
d) It is used to indicate that a method has completed successfully
b) It is used to check if an expression is true; if false, it throws an AssertionError
a) It is used to declare variables with a fixed value
b) It is used to define a new data type that consists of a set of named values
c) It is used to create instances of classes
d) It is used to indicate that a class cannot be subclassed
b) It is used to define a new data type that consists of a set of named values
a) It is used to indicate that a class cannot be subclassed
b) It is used to specify that a class should be loaded in a strict order
c) It is used to define a strict file path
d) It is used to ensure consistent floating-point calculations across different platforms and processors
d) It is used to ensure consistent floating-point calculations across different platforms and processors
a) It is used to indicate that a method is static
b) It is used to call a superclass constructor or method
c) It is used to create a new instance of a class
d) It is used to define a superclass for a class
b) It is used to call a superclass constructor or method
a) It terminates the loop
b) It skips the current iteration of the loop and continues with the next iteration
c) It exits the loop
d) It reverses the loop's direction
b) It skips the current iteration of the loop and continues with the next iteration
a) It indicates that a variable has a default value
b) It indicates that a class has default behavior
c) It indicates that a variable is accessible only within its own class
d) It indicates that a variable is accessible within the same package and not outside the package
d) It indicates that a variable is accessible within the same package and not outside the package
a) It is used to define a type of exception
b) It is used to indicate that a class cannot be subclassed
c) It is used to define a new data type that consists of a set of named values
d) It is used to define a contract for implementing methods in a class
d) It is used to define a contract for implementing methods in a class
a) It is used to declare resources
b) It is used to handle exceptions
c) It is used to create a new instance of a class
d) It is used to automatically close resources after they are no longer needed
d) It is used to automatically close resources after they are no longer needed
a) It is used to indicate that a method is native to a specific operating system
b) It is used to declare a variable as a constant
c) It is used to define a native data type
d) It is used to indicate that a method cannot be overridden
a) It is used to indicate that a method is native to a specific operating system
a) It indicates that a variable is accessible only within its own class
b) It indicates that a variable is accessible within the same package and not outside the package
c) It indicates that a class cannot be subclassed
d) It indicates that a class has default behavior
b) It indicates that a variable is accessible within the same package and not outside the package
Continue P2