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

Explain the overview of UDP messaging.

0 Answers  


What is the output of the following Java program? class Main { public static void main(String args[]){ final int i; i = 10; System.out.println(i); } } 10. What is the output of the following Java program? class Main { public static void main(String args[]){ final int i; i = 10; System.out.println(i); } }

1 Answers  


What is the purpose of assert keyword used in jdk1.4.x?

0 Answers  


Can u write constructor in abstract.If yes den when it will be invoked.

4 Answers   SunGard,


How is string immutable in java?

0 Answers  






Why bytecode is called bytecode?

0 Answers  


Mention some interfaces implemented by linked list in java.

0 Answers  


What is the difference between a choice and a list?

0 Answers  


What does n mean in java?

0 Answers  


How is object created in java?

5 Answers   Cap Gemini,


What about abstract classes in java?

0 Answers  


These static constructors are correct ? class A { statc intA() { } static A(int x,int y) { } static A(int x) { } }

0 Answers   HCL,


Categories