Is it possible to create object with out its default
constructor? if possible how? else not possible? justify
Answers were Sorted based on User's Feedback
Answer / vamsi
Yes, it is possible to create an object without its default
constructor. We can create a parametrized constructor or if
you have not created any thing then the compiler will
provide you with one default constructor.
| Is This Answer Correct ? | 2 Yes | 0 No |
Answer / ravi
class C
{
void show()
{
System.out.println("hi");
}
public static void main(String args[])
{
C c=new C();
c.show();
}
}
we can create object if we don't write the constructor try
execute the above code and see the result; THANK u
| Is This Answer Correct ? | 1 Yes | 0 No |
Answer / suresh royal
yes we can create object without using default constructor.
we can use argument constructor...
this is the example prg
===========================================
class ExArgCon
{
ExArgCon(int a)
{
System.out.println("arg constroctor");
}
public void m1()
{
System.out.println("m1() method");
}
public static void main(String[] args)
{
ExArgCone = new ExArgCon(10);
e.m1();
}
}
| Is This Answer Correct ? | 1 Yes | 0 No |
Can you access the private method from outside the class?
Can subclass overriding method declare an exception if parent class method doesn't throw an exception?
Can a top level class be private or protected?
What are the steps that are followed when two computers connect through tcp?
How do you initialize an arraylist in java?
What is default size of arraylist in java?
how can be object class inherited to all class in a program when java does not support multiple inheritance??
what is the use of private constructor in core java?
3 Answers OnMobile, Satyam, Yash Technologies,
What is the difference between error and an exception?
what is the main differene between synchronize() method and Synchronize{}block?
What is the difference between throw and throws?
Why are parameters used in functions?