What do u mean by method and also contructer in java ?

Answers were Sorted based on User's Feedback



What do u mean by method and also contructer in java ?..

Answer / 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

What do u mean by method and also contructer in java ?..

Answer / 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

What do u mean by method and also contructer in java ?..

Answer / javachi

A method is a procedure to call the objects with their properties within or outside the classes, method is considered in object oriented programming as functions in structured programming.

constructor is a method used only for initializing the variables of the object class. this will reduce the code compatibility.

Is This Answer Correct ?    1 Yes 0 No

Post New Answer

More Core Java Interview Questions

What does .equals do in java?

0 Answers  


How many bytes is a character?

1 Answers  


If there is no implementation of MARKER INTERFACE in java. Then how compiler come to know about specification.

2 Answers  


What is difference between static variable and global variable?

0 Answers  


hi am an engineering student and my next plan is for ms in either in us or australia i got my passport but i dont know anything bout visa can u give brief idea 1)How to get prepared for visa and 2)How to apply for top universities and 3)How to pay the fee and so on These all are basic questions plz give me a clear idea

0 Answers  


how to connect one jsp page to another jsp page????

6 Answers   IIT, Symphony,


Can a class be defined inside an interface?

0 Answers  


What is the static import?

0 Answers  


different between exception and error? explaim check and uncheck exception

4 Answers  


Explain the role played by Java Virtual Machine in Java Programming?

1 Answers  


Why do we need main method to execute a java program?

1 Answers   Virtusa,


what is static import in java? Explain

0 Answers  


Categories