what is constructer?what are the type of constructer with
example.
Answer Posted / shiva krishna
class Shiva
{
public Shiva() // it is a constructor
{
//code
}
}
class Mainclass
{
public static void main(String args[])
{
Shiva obj=new Shiva();
}
}
explanation: the code written in constructor is
automatically executed when we create object for the
class.no need to call the constructor/method again.
point to note:
constructor must not have any return type
| Is This Answer Correct ? | 1 Yes | 1 No |
Post New Answer View All Answers
Which framework is best for rest api java?
Can I have multiple main methods in the same class?
What is a service layer in java?
How do I run a java project in netbeans?
differences between iterator and spliterator in java se 8?
What is a dao layer in java?
how can we create the ui using netbeans,having the code?
What is java persistence api used for?
Is it better to learn java or python?
What is lambda expressions action func and predicate?
What is the point of lambda expressions?
Java prints out a ton of digits when I system.out.println() a double. How can I format it so it displays only 3 digits after the decimal place?
How do you check if java is installed on windows command prompt?
What is interceptors in java?
What is transient in java?