Differentiate constructor and a method and how are it be
used?
Answer Posted / teju
constructor: It is one special member function.it has name same like class .it does not have any return type.it gets executed when we create an object of class and invokes implicitly. constructor is used to initialize the variables ,start the thread
method:
it gets executed explicitly when object is created . it has return type .
method is used to invoke the task or block of code
Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
What is the difference between compile-time polymorphism and runtime polymorphism?
What is the difference between inheritance and encapsulation?
What will happen if a thrown exception is not handled?
Name few java 8 annotations ?
What is the old name of java?
What is the difference between integer parseint and integer valueof?
What is immutable data?
How do you convert bytes to character in java?
How do you sort arrays in java?
How many static init can you have?
What is a lock or purpose of locks in java?
What do you mean by formatting?
Program to Find the second largest element in an array.
Why string is immutable with example?
What is classname class in java?