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 makes a function well defined?

782


What is the difference between procedural and object-oriented programs?

740


Which container method is used to cause a container to be laid out and redisplayed in java programming?

874


Explain about complier design(phases)

853


What is identifier give example?

796


What is scope & storage allocation of global and extern variables? Explain with an example

807


What is the hashcode () and equals () used for?

737


What is the base class of all exception classes in java?

810


What does the ‘static’ keyword mean? Is it possible to override private or static method in java?

778


Which number is denoted by leading zero in java?

1035


Where is java located?

751


How does sublist works in java?

745


Explain notifyall() method of object class ?

875


What super () does in java?

688


What is an argument in java?

714