Ask Question

Which of the following could be a constructor for the public class MyClass? a. public MyClass () b. public void MyClass () c. public MyClass (int a, double b)

+1
Answers (1)
  1. 28 March, 17:07
    0
    A) public MyClass ()

    C) public MyClass (int a, double b)

    Explanation:

    In Java Constructors are special methods used to initialize objects of a class and they are called when a new object is created with the new keyword.

    Being a special method a constructor cannot not have a return type ... not even void.

    The name of the constructor must match the name of the class and constructors can also have parameter (s)
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “Which of the following could be a constructor for the public class MyClass? a. public MyClass () b. public void MyClass () c. public ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers