0% found this document useful (0 votes)
12 views2 pages

Java Modal Ans

A constructor is a special function in a class that initializes data members when an object is created, with types including Default, Parameterized, Copy, and Dynamic Constructors. Java features include simplicity, platform independence, security, robustness, multithreading, portability, and high performance. The finalize() method is used for cleanup operations before an object is destroyed, allowing resource release, with a specific syntax provided.
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)
12 views2 pages

Java Modal Ans

A constructor is a special function in a class that initializes data members when an object is created, with types including Default, Parameterized, Copy, and Dynamic Constructors. Java features include simplicity, platform independence, security, robustness, multithreading, portability, and high performance. The finalize() method is used for cleanup operations before an object is destroyed, allowing resource release, with a specific syntax provided.
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

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]();
}

You might also like