Can we create object of class with private constructor?
Answers were Sorted based on User's Feedback
Answer / 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 |
Answer / rajneesh
Public class mainclass
{
private static mainclass _obj = null;
private constr()
{
}
public static mainclass obj
{
get
{
return _obj
}
}
}
after that you can access the obj in other class .
Is This Answer Correct ? | 0 Yes | 1 No |
Answer / supriya
No we cannot create the objects of class with private
constructor outside the class
Is This Answer Correct ? | 0 Yes | 1 No |
Answer / rahul dhangar
class Rahul
{
private:
int a,b,c;
Rahul()
{ cout<<"enter the no";
cin>>a>>b;
c=a+b;
cout<<c;
}
};
void main()
{
Rahul();
getch();
}
Is This Answer Correct ? | 0 Yes | 4 No |
What is the full form of oops?
what is the diffrence between c# and c++
Give an example where we have to specifically use C programming language and C++ programming language cannot be used?
define a string class. overload the operator == to compare two strings
2 Answers Birla, Ericsson, HCL, Infosys, Infotech, MCAS, Satyam,
1234554321 1234 4321 123 321 12 21 1 1 12 21 123 321 1234 4321 1234554321
Question: Write a program that prints a paycheck. Ask the program user for the name of the employee, the hourly rate, and the number of hours worked. If the number of hours exceeds 40, the employee is paid “time and a half”, that is, 150 percent of the hourly rate on the hours exceeding 40. Be sure to use stepwi se refine ment and break your solution into several functions. Use the int_name function to print the dollar amount of the check.
what is the function of 'this' operator ?
Why do we use oop?
why freind function takes more parameter than normal member function in c++?
What are different types of JVM's? for example we use dalvik jvm for android then what about the remaining operating systems?
Why many objects can working together? How objects working togetherM I want to see example code.
How Do you Code Composition and Aggregation in C++ ?