- here we can create object in 6 ways. They are
- by using new keyword
eg: test t=new test();
- by using factory method
eg: thread t= thread.currentthread();
- by using a method of java class that return other class object
eg: integer i=new integer(10);
String s=i. toString ();
Here toString is the method of java.lang.Integer class, constructing or returning another java class object called string object
- by using cloning operator,
- by using newInstance() method
- by using deserialization
No comments:
Post a Comment