Can we create object of class with private constructor?
Answer Posted / fareed
yes we can
public class Person{
privat Person(){
}
public hai(){
System.out.prinln("hai guys");
}
public static Person getobj(){
return new Person();
}
public class Manage{
public static void main(String[] args){
Person pr=Person.getobj();
pr.hai();
}
}
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
What is the significance of classes in oop?
Which language is not a true object oriented programming language?
What is Difference Between Inheritance and creating object and getting data? means Class A extends B{ B.getMethod();} (OR) Class A{ b obj=new B(); obj.getMethod(); }
What is oops concept with example?
String = "C++ is an object oriented programming language.An imp feature of oops is classes and objects".Write a pgm to count the repeated words from this scenario?
i=20;k=0;
for(j=1;k-i;k+=j<10?4:3)
{
cout< what are the ways in which a constructors can be called? What is the advantage of oop over procedural language? What is encapsulation c#? Why interface is used? What is overriding vs overloading? What is object in oops? Describe these concepts: Polymorphism, Inheritance and Abstraction. Can main method override? Is react oop?