in Technology by
What is the difference between a constructor and a method?

1 Answer

0 votes
by

A constructor is a special type of method that is used to create an object and initialize its data members. A method is a function that is associated with an object and can be called on an object to perform a specific action.

Related questions

0 votes
    What is the difference between method overloading and method overriding?...
asked Feb 9, 2023 in Technology by JackTerrance
0 votes
    Can an abstract class have a constructor?...
asked Feb 9, 2023 in Technology by JackTerrance
0 votes
    What is true about private constructor? (a) Private constructor ensures only one instance of a class exist at ... questions and answers pdf, java interview questions for beginners...
asked Oct 26, 2021 in Education by JackTerrance
0 votes
    What is false about constructor? (a) Constructors cannot be synchronized in Java (b) Java does not provide ... questions and answers pdf, java interview questions for beginners...
asked Oct 26, 2021 in Education by JackTerrance
0 votes
    What is true about constructor? (a) It can contain return type (b) It can take any number of ... programming questions and answers pdf, java interview questions for beginners...
asked Oct 26, 2021 in Education by JackTerrance
0 votes
    Abstract class cannot have a constructor. (a) True (b) False I have been asked this question in ... programming questions and answers pdf, java interview questions for beginners...
asked Oct 26, 2021 in Education by JackTerrance
0 votes
    What is true about protected constructor? (a) Protected constructor can be called directly (b) Protected ... questions and answers pdf, java interview questions for beginners...
asked Oct 26, 2021 in Education by JackTerrance
0 votes
    What would be the behaviour if one parameterized constructor is explicitly defined? (a) Compilation error (b) ... questions and answers pdf, java interview questions for beginners...
asked Oct 26, 2021 in Education by JackTerrance
0 votes
    What happens if constructor of class A is made private? (a) Any class can instantiate objects of class ... questions and answers pdf, java interview questions for beginners...
asked Oct 26, 2021 in Education by JackTerrance
0 votes
    Which of this keyword can be used in a subclass to call the constructor of superclass? (a) super ( ... programming questions and answers pdf, java interview questions for beginners...
asked Oct 26, 2021 in Education by JackTerrance
0 votes
    Which of these is correct way of calling a constructor having no parameters, of superclass A by subclass B? ... questions and answers pdf, java interview questions for beginners...
asked Oct 26, 2021 in Education by JackTerrance
0 votes
    What is the difference between length() and size() of ArrayList? (a) length() and size() return ... programming questions and answers pdf, java interview questions for beginners...
asked Oct 25, 2021 in Education by JackTerrance
0 votes
    What is the difference between TreeSet and SortedSet? (a) TreeSet is more efficient than SortedSet (b) ... questions and answers pdf, java interview questions for beginners...
asked Oct 25, 2021 in Education by JackTerrance
0 votes
    What is difference between dequeue() and peek() function of java? (a) dequeue() and peek() remove ... programming questions and answers pdf, java interview questions for beginners...
asked Oct 25, 2021 in Education by JackTerrance
0 votes
    What is the difference between Queue and Stack? (a) Stack is LIFO; Queue is FIFO (b) Queue is ... programming questions and answers pdf, java interview questions for beginners...
asked Oct 25, 2021 in Education by JackTerrance
...