chandni jain


{ City } bangalore
< Country > india
* Profession * fresher
User No # 34299
Total Questions Posted # 0
Total Answers Posted # 2

Total Answers Posted for My Questions # 0
Total Views for My Questions # 0

Users Marked my Answers as Correct # 12
Users Marked my Answers as Wrong # 3
Questions / { chandni jain }
Questions Answers Category Views Company eMail




Answers / { chandni jain }

Question { 4644 }

who can we create the object of a class? in how many ways we
can create it (max 5)


Answer

1. Using new keyword
This is the most common way to create an object in java.

MyObject object = new MyObject();

2. Using Class.forName()
If we know the name of the class & if it has a public
default constructor we can create an object in this way.

MyObject object = (MyObject)
Class.forName("subin.rnd.MyObject").newInstance();

3. Using clone()
The clone() can be used to create a copy of an existing object.

MyObject anotherObject = new MyObject();
MyObject object = anotherObject.clone();

4. Using object deserialization
Object deserialization is nothing but creating an object
from its serialized form.

ObjectInputStream inStream = new
ObjectInputStream(anInputStream );
MyObject object = (MyObject) inStream.readObject();

Is This Answer Correct ?    4 Yes 0 No

Question { 13562 }

Love love it.. friends need it.. relationing start with
it.. life ends with it..


Answer

e alphabate

Is This Answer Correct ?    8 Yes 3 No