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
Make a data structure and implement an algorithm to print all the files in a directory. (The root directory can have sub-directories too.)
What is string data?
What is the use of set in java?
What does a boolean method return?
What is the difference between the direct buffer and non-direct buffer in java?
Is integer a class?
What is difference between protected and private?
What is static and final keyword in java?
What is classname class in java?
What is an iterator interface in java programming?
What are keywords and reserved words in java?
How transient variable is different from volatile variable?
What is the difference between overriding and overloading in OOPS.
What is the default value of local and global variables?
Explain about features of local inner class?