0
Can anyone give an example where constructor of a class called but the instantiation of that class not happened?
4 odpowiedzi
+ 5
class somthing{
somthing(){
System.out.print(System.out.print("Class Constructor");
}
}
//main(){
Somthing obj = new Somthing();//Calls constructor
}
+ 5
Sumit Basu yes thats correct the constructor is invoked when the object is created if theres no constructor a default one is created 👍
0
Thank you..but new keyword will create the object of something.. please correct me if I am wrong
0
Thanks Stark..but then object is created anyway by ur program..then how can we achive the scenario..