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
What is an 8 bit word?
How does list work in java?
What is string in java?
Is java programming easy?
What is the purpose of an interface?
What is entry in java?
What does nextint () do in java?
Is empty string in java?
Explain wrapper classes in java?
Explain the difference between arraylist and linkedlist in java?
What is the flag in java?
What is a double vs float?
Hi.... I applied for the post of scientific officer/Engineer-SB(Programmer).Please post the syllabus and sample papers.
How big is a pointer?
In which order the iterator iterates over collection?