Hey Guys welcome to CES Study247,Today I am provide you Java Programming MCQs SET-4
Q.61 The process that focuses on only important characteristics is known as:
Encapsulation
Polymorphism
Abstraction
Inheritance
Explanation
Abstraction is the process of hiding internal details and showing only the essential features of an object.
Q.62 Which statement is true regarding an object:
An object is of a class
An object is an instance of a class
An object is a variable
An object is not an instance of class
Explanation
An object is a basic unit of Object-Oriented Programming and represents a real-life entity; it is created as an instance of a class.
Q.63 An object-oriented programming composition relates to:
The use of consistent coding convection
It refers to coherent, common, behavior
It refers to procedural behavior
None of these
Explanation
Composition is a ‘has-a’ relationship that allows for creating complex types by combining objects of other types, ensuring coherent behavior.
Q.64 In object-oriented programming, new classes can be defined by extending existing classes through:
Encapsulation
Interface
Composition
Inheritance
Explanation
Inheritance is the mechanism by which one class acquires the properties and behaviors of a parent class.
Q.65 Given a class name Book, which one of these is a valid constructor declaration for the class:
Book (Book b) {}
Book Book ()
Final Book ()
Abstract Book ()
Explanation
A constructor must have the same name as the class and no return type. ‘Final’ and ‘Abstract’ are not allowed for constructors. Option A is a valid copy constructor.
Q.66 The wrapping of data and functions into a single unit is called:
Encapsulation
Abstraction
Data hiding
Polymorphism
Explanation
Encapsulation is the technique of making the fields in a class private and providing access via public methods.
Q.67 Polymorphism is a characteristic of:
JAVA language
C language
Cobol language
None of the above
Explanation
Polymorphism is a core pillar of Object-Oriented Programming, which is a fundamental feature of Java.
Q.68 The numerical range of a char data type in Java is:
-128 to 127
0 to 256
0 to 32767
0 to 65535
Explanation
In Java, ‘char’ is a 16-bit unsigned Unicode character, ranging from 0 to 65,535.
Q.69 Which of the following events will cause a thread to die?
The method sleep() is called
The method wait() is called
The execution of start() is called
Execution of run() method is completed
Explanation
A thread moves to the ‘Dead’ or ‘Terminated’ state once it completes the execution of its run() method.
Q.70 Which of the following is true regarding the finalize() method?
It must only be declared with protected accessibility
Finalize() method can be overloaded
Finalize() method cannot be overloaded
All of the above are true
Explanation
The finalize() method is a regular method in that regard and can be overloaded, though only the no-arg version is called by the Garbage Collector.
Q.71 Which of the following is a valid method declaration in Java:
void method 2
int 1 method 1
int method 3 () void
void method ()
Explanation
A valid method declaration requires a return type (or void), a valid identifier (no spaces), and parentheses for parameters.
Q.72 The concept of multiple interface implementations is achieved in Java by:
Extending two or more classes
Extending one class and implementing interfaces
Implementing inheritance
Implementing thread
Explanation
Java does not support multiple inheritance of classes, but a class can extend one superclass and implement multiple interfaces.
Q.73 The File class is included in which package?
java.io
java.lang
java.awt
java.util
Explanation
The File class, used for navigating the file system, is part of the java.io package.
Q.74 What is the sequence of major events in the life cycle of an applet:
init, start, stop, destroy
start, init, stop, destroy
init, start, destroy
init, destroy, stop
Explanation
The standard applet lifecycle follows the order: init() (initialization), start() (execution), stop() (suspension), and destroy() (termination).
Q.75 Threading provides execution of:
Only one module of the program at a time
Only two modules of the program at a time
All related program sub-blocks simultaneously
None of the above
Explanation
Multithreading allows multiple parts of a program (threads) to run concurrently or simultaneously to maximize CPU utilization.
Q.76 Which of these operators is used to allocate memory to an array variable in Java?
Malloc
Alloc
New
New malloc
Explanation
In Java, the ‘new’ keyword is used to allocate memory for both objects and arrays.
Q.77 Which one of the following class definitions is valid and cannot be extended?
Final class link {}
Static class link {}
Abstract class link {}
Class link {}
Explanation
The ‘final’ keyword, when applied to a class, prevents any other class from subclassing or extending it.
Q.78 Which statement is true about the accessibility of members?
Private members are always accessible in the same package
Private members are accessible in the class
Private members are accessible outside the class
None of these
Explanation
Private members of a class are only accessible within the same class in which they are declared.
Q.80 The field in an interface is implicitly specified as:
Static only
Protected
Private
Both static and final
Explanation
Every field (variable) declared in an interface is implicitly public, static, and final.