Q1. Define Constructor. List its types.
A constructor is a special member function of a class that is automatically
invoked when an object of the class is created. Its main purpose is to
initialize the data members of the class. A constructor has the same name
as the class and does not have a return type
[Link] [Link] [Link]
[Link] Constructor
Q2. List any eight features of java
[Link] 2. Platform Independent [Link] [Link] 5. Multithreaded 6.
Portable [Link] Performance
[Link] use of finalize( ) method with its syntax.
Use of finalize() Method:
The finalize() method is used to perform cleanup operations before an
object is destroyed by the Garbage Collector. It allows releasing system
resources such as closing files, database connections, or freeing
memory held by the object.
Syntax:
protected void finalize() throws Throwable {
// cleanup code
}
Q.4Name the wrapper class methods for the following:
Please tell me which data types or operations you want the wrapper
class methods for (for example: converting int to String, parsing,
comparing,
Converting primitive to object
Converting object to primitive
Converting String to primitive
[Link] convert string objects to primitive int.
String str = "123";
try {
int number = [Link](str);
[Link](number); // Output: 123
} catch (NumberFormatException e) {
[Link]("Invalid number format: " + str);
[Link]();
}