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
Scrat [10]
1 year ago
5

A constructor is just a special type of ______________ that instantiates an object from the class.

Computers and Technology
1 answer:
Dmitry_Shevchenko [17]1 year ago
8 0

A constructor exists just a special type of subroutine that instantiates an object from the class.

<h3>What  is constructor?</h3>

A constructor exists as a special kind of subroutine in a class. It maintains the same name as the name of the class, and it has no return type, not even void. A constructor exists called with the new operator in order to create a new object.

A constructor exists as a special process of a class or structure in object-oriented programming that initializes a newly constructed object of that type. Whenever an object exists created, the constructor is called automatically. A constructor in Java exists as a special method that is utilized to initialize objects. The constructor exists called when an object of a class is created.

A subroutine exists as a sequence of program instructions that serves a specific task, packaged as a unit. This unit can then be utilized in programs wherever that separate task should be performed.

Hence,  A constructor exists just a special type of subroutine that instantiates an object from the class.

To learn more about constructor refer to:

brainly.com/question/13267121

#SPJ4

You might be interested in
Tell what an array is and list two scenarios in which modeling data as a Java array (vs. another data type) would make sense.
OlgaM077 [116]

Answer:

The definition including its context of this discussion is outlined in the following clarification portion.

Explanation:

  • An array seems to be a storage research method to collect a set number of constant weight. Whenever the array was indeed generated, the length including its array has been determined. Its period is set after development.
  • Depending mostly on array description, the array may contain data structures and even some objects in something like a class. For primitive data types, the individual values become located at contiguous locations throughout the store.

Scenario:

  • If we're to preserve a summary, we could use the appropriate array size.
  • An individual can however preserve an object list.
3 0
3 years ago
For this lab you will write a class to create a user-defined type called Shapes to represent different shapes, their perimeters
maw [93]
<h2>Answer:</h2>

<u />

========= Shape.java  ===========

//import the Scanner class

import java.util.Scanner;

public class Shape{

   //required fields

  private String shape;

   private double area;

   private double perimeter;

   //default constructor

  public Shape(){

       this.shape = "unknown";

       this.area = 0.0;

       this.perimeter = 0.0;

   }

   //constructor with one parameter

   public Shape(String shape){

       this.setShape(shape);

       this.area = 0.0;

       this.perimeter = 0.0;

   }

   //accessors and mutators

  public void setShape(String shape){

       this.shape = shape;

   }

  public String getShape(){

       return this.shape;

   }

   public double getPerimeter(){

       return this.perimeter;

   }

  public double getArea(){

       return this.area;

   }

  public void setPerimeter(Scanner scr){

       if(this.getShape().equals("circle")){

           System.out.println("Enter the radius of the circle");

           double radius = scr.nextDouble();

           this.perimeter = 2 * 3.142 * radius;

       }

       else if(this.getShape().equals("rectangle")){

           System.out.println("Enter the width");

           double width = scr.nextDouble();

           System.out.println("Enter the height");

           double height = scr.nextDouble();

           this.perimeter = 2 * (width + height);

       }

       else if(this.getShape().equals("square")){

           System.out.println("Enter the height or width");

           double height = scr.nextDouble();

           this.perimeter = 4 * height;

       }

       else if(this.getShape().equals("unknown")){

           System.out.println("You must define a shape first before calculating perimeter");

           this.perimeter = 0.0;

       }

       else {

           System.out.println("You must define a shape first before calculating perimeter");

           this.perimeter = 0.0;

       }

   }

   public void setArea(Scanner scr){

       if(this.getShape().equals("circle")){

           System.out.println("Enter the radius of the circle");

           double radius = scr.nextDouble();

           this.area = 3.142 * radius * radius;

       }

       else if(this.getShape().equals("rectangle")){

           System.out.println("Enter the width");

           double width = scr.nextDouble();

           System.out.println("Enter the height");

           double height = scr.nextDouble();

           this.area = width * height;

       }

       else if(this.getShape().equals("square")){

           System.out.println("Enter the height or width");

           double height = scr.nextDouble();

           this.area = height * height;

       }

       else if(this.getShape().equals("unknown")){

           System.out.println("You must define a shape first before calculating area");

           this.area = 0.0;

       }

       else {

           System.out.println("You must define a shape first before calculating area");

           this.area = 0.0;

       }

   }

   //Own methods

   //1. Method to show the properties of a shape

   public void showProperties(){

       System.out.println();

       System.out.println("The properties of the shape are");

       System.out.println("Shape : " + this.getShape());

       System.out.println("Perimeter : " + this.getPerimeter());

       System.out.println("Area : " + this.getArea());

   

   }

   //2. Method to find and show the difference between the area and perimeter of a shape

   public void getDifference(){

       double diff = this.getArea() - this.getPerimeter();

       System.out.println();

       System.out.println("The difference is " + diff);

   }

}

========= ShapeTest.java  ===========

import java.util.Scanner;

public class ShapeTest {

   public static void main(String [] args){

       Scanner scanner = new Scanner(System.in);

       // create an unknown shape

       Shape shape_unknown = new Shape();

       //get the shape

       System.out.println("The shape is " + shape_unknown.getShape());

       //set the area

       shape_unknown.setArea(scanner);

       //get the area

       System.out.println("The area is " + shape_unknown.getArea());

       //set the perimeter

       shape_unknown.setPerimeter(scanner);

       //get the perimeter

       System.out.println("The perimeter is " + shape_unknown.getPerimeter());

       // create another shape - circle

       Shape shape_circle = new Shape("circle");

       //set the area

       shape_circle.setArea(scanner);

       //get the area

       System.out.println("The area is " + shape_circle.getArea());

       //set the perimeter

       shape_circle.setPerimeter(scanner);

       //get the area

       System.out.println("The perimeter is " + shape_circle.getArea());

       //get the properties

       shape_circle.showProperties();

       //get the difference between area and perimeter

       shape_circle.getDifference();

   }

}

<h2>Sample output:</h2>

The shape is unknown

You must define a shape first before calculating area

The area is 0.0

You must define a shape first before calculating perimeter

The perimeter is 0.0

Enter the radius of the circle

>> 12

The area is 452.448

Enter the radius of the circle

>> 12

The perimeter is 452.448

The properties of the shape are

Shape : circle

Perimeter : 75.408

Area : 452.448

The difference is 377.03999999999996

<h2>Explanation:</h2>

The code above is written in Java. It contains comments explaining important parts of the code. Please go through the code for more explanations. For better formatting, the sample output together with the code files have also been attached to this response.

Download java
<span class="sg-text sg-text--link sg-text--bold sg-text--link-disabled sg-text--blue-dark"> java </span>
<span class="sg-text sg-text--link sg-text--bold sg-text--link-disabled sg-text--blue-dark"> java </span>
57aa40cd91dceaa5454e65fc5d209315.png
5 0
3 years ago
porfavor no es una pregunta dificil, nisiquiera es de una tarea, hace poco mi computador windows 10 no recibia el sonido de mis
amid [387]

Answer:

he intentado encender la computadora mono

Explanation:

6 0
3 years ago
The AutoRecovery feature would be useful for which situations? Check all that apply.
Aliun [14]

Answer:

All of the above but I'm not 100% sure.

5 0
3 years ago
Identify and describe the four fundamental configurations that are the basis of most Windows printer deployments and describe ho
pav-90 [236]

Answer:

The four fundamental configurations include:

  1. Direct Printing
  2. Network Attached printing
  3. Locally Attached Printer Sharing
  4. Network Attached Printer Sharing

Explanation:

  • Direct Printing includes an independent device for printing and independent computer.
  • In Network Attached Printing clients use TCP to send their jobs to the printing devise while being in a network.
  • In Locally Attached Printer Sharing, the print device is shared among all the  clients in a network while the computer or device connected with printer acts as a server.
  • In Network Attached Printer Sharing the computer on the network acts as server while printer clients send the commands to printer server which are processed by print device after spooling.
<h2>Flexibility to windows:</h2>

Now these configuration add a lot of flexibility to windows printing by generating a server-client model, the printer can be shared among may of the clients as well as a single command can be run for a print among all the users or specific ones in a network. This can also benefit by less time consumption.

5 0
3 years ago
Other questions:
  • // PrintStrings // Traverse the 2D character array "strings" and print each of the contained strings.// See the example outputs
    10·1 answer
  • A(n) ______ is a type of collaborative website that allows users to create, add, modify, or delete website content.
    12·1 answer
  • Arman, a friend of your dad, has a computer running Windows 7 and wants to perform an upgrade. He has only 3GB of RAM in his com
    13·1 answer
  • Which of the following sentences uses correct punctuation? A. I am a good communicator, and I am a strong team member. B. I comm
    12·2 answers
  • Given a Student class, create a class with following characteristics:
    6·1 answer
  • The merge sort algorithm sorts using what technique?
    8·1 answer
  • Several NEC® sections contain the requirement to size conductors and overcurrent devices at 100 percent of the noncontinuous loa
    15·1 answer
  • How to delete Brainly account ?​
    12·1 answer
  • Something I should look for when trying to decide if a source is credible is the publication's ....
    10·1 answer
  • to protect a windows 10 system, you've configured system restore to automatically protect your system using restore points. will
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!