What do u mean by method and also contructer in java ?
Answer Posted / prachi
Java methods are similar to functions or procedures in other
programming languages.
Every Java program must have one main() method.
Here is the main() method from a Java program which prints
"Hello World":
public static void main (String[] args) {
// This Java program prints "Hello World!"
System.out.println{"Hello World!");
A constructor creates an Object of the class that it is in
by initializing all the instance variables and creating a
place in memory to hold the Object. It is always used with
the keyword new and then the Class name. For instance, new
String(); constructs a new String object.
COnstructors are basically used to initialize the attributes
of the class.
| Is This Answer Correct ? | 2 Yes | 0 No |
Post New Answer View All Answers
Why is the type for real numbers called double?
What is the use of parseint in java?
Give me an example of array and linked list? Where they can be used?
what is use of functional interface in java 8?
What is nan in java?
What do you meant by active and passive objects?
What classes of exceptions may be thrown by a throw statement?
What is the private method modifier?
What is boolean law?
how to create daemon thread in java?
Tell us something about an iterator.
how to deploy tomcatserver to weblogic server? write d following steps?
How can we find the sum of two linked lists using stack in java?
Explain the JDB in depth & command line.
What restrictions are placed on method overriding in java programming?