1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Gnesinka [82]
3 years ago
5

Constructors have the same name as the ____.1. data members2. member methods3. class4. package

Computers and Technology
1 answer:
Svetradugi [14.3K]3 years ago
8 0

Answer:

(3) option is the correct answer.

Explanation:

Constructors need to initialize the object in the memory. "To declare the Constructor for any class the user needs to specify the constructor name which is already the class name". This is an object-oriented language guideline.

It is because the object is created by the name of the class and Constructor is used to allocate the memory for the object. hence Constructor is created by the name of the class.

For example--

                       class test //class name test

                      {

                               test() //created a constructor with class name "test"

                               {

                               }

                      }

In the above example class name and constructor name are same if it not then it will gives a error.

Another option is not valid for the answer to the above problem because-

  • Option 1 is wrong because, for any class, the data member is a type of variable, which is used to store the data and is accessed with the help of an object.
  • Option 2 is wrong because, for any class, member function is a type of user function used to accessed the variable and expressions.
  • Option 4 is wrong because, package is a set used to hold classes and interfaces.

You might be interested in
Look at the following structure declaration.
myrzilka [38]

Answer:

B. a tag

Explanation:

In the structure definition given below:

struct Employee

{

string name;

int idNum;  

};

Employee corresponds to the tag of the structure. The tag is used to create additional instances of the structure. For example:

struct Employee e1;

struct Employee e2;

name and idNum are members of the Employee structure and are referenced using the dot notation. e.g.,

struct Employee e1;

e1.idNum=1;

7 0
2 years ago
______ behavior expected from every professional​
Shalnov [3]

Answer:

Respectful

Explanation:

3 0
2 years ago
What is the purpose of a report?
Tanzania [10]
C to organize data in a table
4 0
3 years ago
A sosit vara.copiii sunt veseli pentru ca au luat vacanta,mii de fluturi colorati zboara pe ceruri senine,soarele straluceste ve
hodyreva [135]
Acest lucru nu este calculator și tehnologie acest lucru arata ca acesta poate fi un poem pare rău, dar acest lucru trebuie postat in categoria engleză!! Mulțumesc

4 0
2 years ago
If myClass has a constructor with a parameter of type String, select the other constructor that should be included.
JulijaS [17]

Answer:

d. public myClass( ) {. . .}

Explanation:

A constructor is a special method that is called when an object of a class is created. It is also used to initialize the instance variables of the given class. A class may have one or more constructors provided that these constructors have different signatures. A class that does not have a constructor explicitly defined has a default parameterless constructor.

Having said these about a constructor, a few other things are worth to be noted by a constructor.

i. In Java, a constructor has the same name as the name of its class.

For example, in the given class <em>myClass</em>, the constructor(s) should also have the name <em>myClass</em>.

ii. A constructor does not have a return value. It is therefore wrong to write a constructor like this:

<em>public void myClass(){...}</em>

This makes option a incorrect.

iii. When a constructor with parameters is defined, the default parameterless constructor is overridden. This might break the code if some other parts  of the program depend on this constructor. So it is advisable to always explicitly write the default parameterless constructor.

This makes option d a correct option.

Other options b and c may also be correct but there is no additional information in the question to help establish or justify that.

7 0
3 years ago
Other questions:
  • Plz tell me a storage device that should be used for this and why
    11·1 answer
  • With respect to the general classes of computers, a ________ is the most expensive and most powerful kind of computer, which is
    7·1 answer
  • __________ was the first operating system to integrate security as its core functions.
    15·2 answers
  • Web pages often have built-in connections, or links, to other documents, graphics, other web pages, or web sites. true or false?
    9·1 answer
  • ____ contain instructions for the OS for hardware devices, such as the keyboard, mouse, and video card, and are stored in the sy
    15·1 answer
  • Identify two entities and 2 of their attributes from the given scenario.
    9·1 answer
  • MICR is an input or output devices
    5·1 answer
  • Consider the code below. When you run this program, what is the output if the temperature is 77.3 degrees Fahrenheit?
    6·1 answer
  • Aii so is anyone pushing P?<br> if u are u a g
    8·2 answers
  • Question 12 (5 points)
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!