What do u mean by method and also contructer in java ?
Answer Posted / hira ratan sharma
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 ? | 6 Yes | 0 No |
Post New Answer View All Answers
Does treeset allow null in java?
Can a final variable be null?
What is jit and its use?
What is lazy programming?
What is the difference between static and non-static variables in java programming?
What sorting algorithm does javascript use?
What is nullpointerexception in java?
Which is illegal identifier in java?
What does you mean in math?
Why do we override tostring method in java?
What is difference between class and object in java?
What is data and its types?
Why string is immutable with example?
What are the differences between abstract class and interface?
What is data member in java?