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 immutable state?
What is a conditional equation?
What is the platform?
What is high level language in computer?
What is the difference between replace and replace all?
What are the advantages of assembly language?
What is a get method?
What is a parameter example?
Can a class be private?
What is an iterator java?
What is a default method?
Is break statement can be used as labels in java?
Explain reverse a linked list recursive java solution?
What does t in java mean?
Can we have more than one package statement in the source file?