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


Please Help Members By Posting Answers For Below Questions

Does treeset allow null in java?

729


Can a final variable be null?

765


What is jit and its use?

788


What is lazy programming?

788


What is the difference between static and non-static variables in java programming?

725


What sorting algorithm does javascript use?

764


What is nullpointerexception in java?

755


Which is illegal identifier in java?

804


What does you mean in math?

792


Why do we override tostring method in java?

695


What is difference between class and object in java?

762


What is data and its types?

777


Why string is immutable with example?

733


What are the differences between abstract class and interface?

768


What is data member in java?

694