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

Is integer passed by reference in java?

572


What do you mean by platform independence?

586


What do the thread?class methods run() and start() do?

547


Explain creating threads by extending thread class ?

580


What is the different types of functions?

563






What is a treeset in java?

549


What is the purpose of the main method?

545


What are the benefits of immutable objects?

544


Can we create constructor in abstract class ?

586


Given a singly linked list, how will you print out its contents in the reverse order? Can you do it with consuming any extra space?

609


What is lazy programming?

571


Where can I find jdk in my computer?

468


Which programming language is most secure?

537


What are the different collection views provided by maps?

573


How is it possible in java programming for two string objects with identical values not to be equal under the == operator?

569