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


Please Help Members By Posting Answers For Below Questions

What is an 8 bit word?

590


How does list work in java?

502


What is string in java?

556


Is java programming easy?

537


What is the purpose of an interface?

550






What is entry in java?

529


What does nextint () do in java?

552


Is empty string in java?

536


Explain wrapper classes in java?

528


Explain the difference between arraylist and linkedlist in java?

484


What is the flag in java?

608


What is a double vs float?

533


Hi.... I applied for the post of scientific officer/Engineer-SB(Programmer).Please post the syllabus and sample papers.

1507


How big is a pointer?

546


In which order the iterator iterates over collection?

579