what is constructer?what are the type of constructer with
example.
Answer Posted / prasad
A constructor is a method.it used to custom intialization
for an object.constructor name and class name is same.
consructor should not return any value not even void also.
A constructor will Executed at the time of initialization of
an object.
Different types of constructors:
--------------------------------
1)default constructor
2)parametarized constructor
Ex:
class sum{
int a,b;//instance variables
sum(int a,int b){
System.out.printl("sum of two numbers="+(a+b));
}
}
class Example{
psvm(String s[])throws Exception{
sum s=new sum(10,10);
}
}
o/p:sum of two numbers=20
/*here the constructor will be executed at the time of
creating the object*/
| Is This Answer Correct ? | 0 Yes | 2 No |
Post New Answer View All Answers
Who developed rxjava?
How do I run a java project?
What is hql in java?
What is Map,List,hashtable,ArrayList and difference between them??
when i send the request to the JSP page it will print as it is and why? and how to solve this problem please inform me that solution
For each of the following program segments,give a big zero
analysis for the running time
1.For (i=0;i What is injection in java? Which framework is best for rest api java? What is jpa used for? What is loose coupling in java? What is stateless class in java? What is connection pooling in java? How many types of jdk are there? What is java persistence api used for? What is entitymanager in java?