Starting out with Visual C# (4th Edition)
4th Edition
ISBN: 9780134382609
Author: Tony Gaddis
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Concept explainers
Textbook Question
Chapter 9.3, Problem 9.14CP
What happens if you write a class with no constructor whatsoever?
Expert Solution & Answer
Trending nowThis is a popular solution!
Students have asked these similar questions
I have multiple constructors defined in a class. Is it possible to call a constructor from another constructor’s body?
Python
What method is automatically executed whenever a new instance of the class, which the method belongs to, has been instantiated?
a. encapsulation
b. abstraction
c. polymorphism
Chapter 9 Solutions
Starting out with Visual C# (4th Edition)
Ch. 9.1 - How is a class like a blueprint?Ch. 9.1 - Briefly describe the process of writing a class...Ch. 9.1 - What is a constructor?Ch. 9.1 - Prob. 9.4CPCh. 9.1 - When you pass an object that is an instance of a...Ch. 9.2 - What is a property?Ch. 9.2 - Prob. 9.7CPCh. 9.2 - Prob. 9.8CPCh. 9.2 - Prob. 9.9CPCh. 9.2 - Prob. 9.10CP
Ch. 9.3 - What is a parameterized constructor?Ch. 9.3 - Prob. 9.12CPCh. 9.3 - Prob. 9.13CPCh. 9.3 - What happens if you write a class with no...Ch. 9.3 - Describe the purpose of the default constructor.Ch. 9.4 - Prob. 9.16CPCh. 9.4 - How can you initialize an array of a class type...Ch. 9.4 - Prob. 9.18CPCh. 9.5 - Prob. 9.19CPCh. 9.5 - When designing an object-oriented application, who...Ch. 9.5 - How do you identify the potential classes in a...Ch. 9.5 - What are a classs responsibilities?Ch. 9.5 - What two questions should you ask to determine a...Ch. 9.5 - Will all a class's actions always be directly...Ch. 9.6 - Prob. 9.25CPCh. 9.6 - Prob. 9.26CPCh. 9.6 - Prob. 9.27CPCh. 9.6 - Prob. 9.28CPCh. 9.6 - Prob. 9.29CPCh. 9 - Each object that is created from a class is called...Ch. 9 - Prob. 2MCCh. 9 - The first line of a class declaration is known as...Ch. 9 - The classs________ are the statements that define...Ch. 9 - A(n) _____ is a method that is automatically...Ch. 9 - A(n) is a special type of class member that allows...Ch. 9 - A special set of methods, known as_________, work...Ch. 9 - Prob. 8MCCh. 9 - The parameter of the set accessor is automatically...Ch. 9 - A can be read, but it cannot be modified. a....Ch. 9 - When the value of an item is dependent on other...Ch. 9 - A constructor that accepts arguments is known as...Ch. 9 - Prob. 13MCCh. 9 - Prob. 14MCCh. 9 - A methods ______ consists of the methods name and...Ch. 9 - A is a constructor that accepts no arguments. a....Ch. 9 - If you write a class with no constructor...Ch. 9 - Prob. 18MCCh. 9 - A classs responsibilities are_______. a. the...Ch. 9 - Prob. 20MCCh. 9 - Objects that are instances of a class are always...Ch. 9 - Prob. 2TFCh. 9 - A class is an object.Ch. 9 - It is a common practice to make all a classs...Ch. 9 - The same rules for naming variables apply to...Ch. 9 - If you need to make a property read only, you...Ch. 9 - If you try to pass a property to a ref or an out...Ch. 9 - Class fields are almost always declared public in...Ch. 9 - The get accessor can be thought of as a method...Ch. 9 - Constructors can accept arguments in the same way...Ch. 9 - It is legal to write a class without any...Ch. 9 - Objects that are instances of a class can be...Ch. 9 - Prob. 13TFCh. 9 - One way to find the classes needed for an...Ch. 9 - Prob. 15TFCh. 9 - By default, a controls Modifiers property is set...Ch. 9 - Prob. 1SACh. 9 - What are the advantages of storing classes in...Ch. 9 - How is a constructor used?Ch. 9 - What is the difference between a class and an...Ch. 9 - What convention do most programmers follow when...Ch. 9 - What is the value parameter? How is it created?Ch. 9 - What is executed any time a class property is...Ch. 9 - What is executed any rime a value is assigned to a...Ch. 9 - How can you protect class fields from accidental...Ch. 9 - Prob. 10SACh. 9 - Is it possible to pass initialization values to...Ch. 9 - How does the compiler distinguish a method from...Ch. 9 - What do you call the constructor that is provided...Ch. 9 - Prob. 14SACh. 9 - Prob. 15SACh. 9 - Prob. 16SACh. 9 - Prob. 17SACh. 9 - Write a statement that creates an instance of the...Ch. 9 - Write the accessors for a property named...Ch. 9 - Prob. 3AWCh. 9 - Look at the following description of a problem...Ch. 9 - Pet Class Create a class named Pet (similar to the...Ch. 9 - Car Class Create a class named Car that has the...Ch. 9 - Personal Information Class Create a class that...Ch. 9 - Employee Class Write a class named Employee that...Ch. 9 - RetailItem Class Write a class named RetailItem...Ch. 9 - Dorm and Meal Plan Calculator A university has the...Ch. 9 - E-Mail Address Book Create an application with a...
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
Write a program that reads three whole numbers and displays the average of the three numbers.
Java: An Introduction to Problem Solving and Programming (8th Edition)
Explain in detail how the increment method works.
Objects First with Java: A Practical Introduction Using BlueJ (6th Edition)
Write a program to print the value of EOF.
C Programming Language
A file that contains a Flash animation uses the __________ file extension. a. .class b. .swf c. .mp3 d. .flash
Web Development and Design Foundations with HTML5 (9th Edition) (What's New in Computer Science)
Modify the program in the previous exercise so that it reads the name of the file from the keyboard.
Java: An Introduction to Problem Solving and Programming (7th Edition)
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- What are the benefits of passing this into a method rather than the current class object?arrow_forwardWrite a Rectangle class that has the following fields: Length (L): a double Width (W): a double The class should have the following functions: Constructor: accepts the length (L) and the width (W) of a rectangle as arguments. Constructor: does not take any parameters and initializes the length(L) and width(W) to zero. A function called getArea which returns the area of the rectangle. A function called getPerimeter which returns the perimeter of the rectangle. {note: The area of a rectangle = L*W, and its perimeter = 2*(L+W) } Then, write a program to ask the user to enter the length and width of a rectangle, and then use the above class to calculate and print the area and perimeter of the rectangle.arrow_forwardJava A class always has a constructor that does not take any parameters even if there are other constructors in the class that take parameters. Choose one of the options:TrueFalsearrow_forward
- Object Oriented Programming in JAVA You are part of a team writing classes for the different game objects in a video game. You need to write classes for the two human objects warrior and politician. A warrior has the attributes name (of type String) and speed (of type int). Speed is a measure of how fast the warrior can run and fight. A politician has the attributes name (of type String) and diplomacy (of type int). Diplomacy is the ability to outwit an adversary without using force. From this description identify a superclass as well as two subclasses. Each of these three classes need to have a default constructor, a constructor with parameters for all the instance variables in that class (as well as any instance variables inherited from a superclass) accessor (get) and mutator (set) methods for all instance variables and a toString method. The toString method needs to return a string representation of the object. Also write a main method for each class in which that class is…arrow_forwardHow many default constructors can a class have? a. A class cannot have a default constructor. b. only one c. as many as it needs d. one or more, but fewer than threearrow_forwardComplete the code for the following program. You are provided with an abstract class called abst. Create a class that will be a child of abst and it will be called usesAbst. Your program will have an int variable called value, and all the appropriate methods, as well 2 constructors. The first constructor will simply set the variable value to 0. The second constructor will set the variable value to equal a passed in parameter. You do not have to comment your code. public abstract class abst{ public abst () { } //Outputs to the screen the message Hello public abstract void sayHello (); //returns the stored int value public abstract int getValue (); //sets the int value to x public abstract void setValue (int x); //Outputs to the screen the message Another method public void output () { System.out.println("Another method"); public String tostring () { return "This is an abstract class"; }arrow_forward
- What are the advantages of passing this data into a method as opposed to just passing it into the current class object?arrow_forwardStatic members of a class are... When and how can you take advantage of these opportunities?arrow_forwardModify the Car class example and add the following: A default constructor that initializes strings to “N/A” and numbers to zero. An overloaded constructor that takes in initial values to set your fields (6 parameters). accel() method: a void method that takes a double variable as a parameter and increases the speed of the car by that amount. brake() method: a void method that sets the speed to zero. To test your class, you will need to instantiate at least two different Car objects in the main method in the CarDemo class. Each of your objects should use a different constructor. For the object that uses the default constructor, you will need to invoke the mutator methods to assign values to your fields. Invoke the displayFeatures() method for both objects and display the variables. Demonstrate the use of the accessor method getColor() by accessing the color of each car and printing it to the console. Use the method accel to increase the speed of the first car by 65 mph. Use…arrow_forward
- Code the StudentAccount class according to the class diagramMethods explanation:pay(double): doubleThis method is called when a student pays an amount towards outstanding fees. The balance isreduced by the amount received. The updated balance is returned by the method.addFees(double): doubleThis method is called to increase the balance by the amount received as a parameter. The updatedbalance is returned by the method.refund(): voidThis method is called when any monies owned to the student is paid out. This method can onlyrefund a student if the balance is negative. It displays the amount to be refunded and set thebalance to zero. (Use Math.abs(double) in your output message). If there is no refund, display anappropriate message.Test your StudentAccount class by creating objects and calling the methods addFees(), pay() andrefund(). Use toString() to display the object’s data after each method calledarrow_forwardwrite in java Write a CashRegister class that can be used with the RetailItem class that you wrote inChapter 6’s Programming Challenge 4. (in the attachments) The CashRegister class should simulate the sale ofa retail item. It should have a constructor that accepts a RetailItem object as an argument.The constructor should also accept an integer that represents the quantity of items beingpurchased. In addition, the class should have the following methods:• The getSubtotal method should return the subtotal of the sale, which is the quantitymultiplied by the price. This method must get the price from the RetailItem objectthat was passed as an argument to the constructor.• The getTax method should return the amount of sales tax on the purchase. The salestax rate is 6 percent of a retail sale.• The getTotal method should return the total of the sale, which is the subtotal plus thesales tax.Demonstrate the class in a program that asks the user for the quantity of items being purchased,and…arrow_forwardProblem Class In this exercise, you are going to create the Problem class. The Problem class is used to help simulate a math fact, for example: 2+5= Your class needs to contain two constructors, one that takes String, int, int that represents the operator sign(+,-, *, or /), the minimum, and maximum values for the number range, and a second constructor that takes only a String that represents the operator sign. For the second constructor, the minimum should default to zero and the maximum to ten. Your Problem object should generate 2 random integers between the minimum and maximum values (inclusively). Each Problem object should only have one set of numbers that do not change. While you may include additional helper methods, two methods need to be available to the user. The first is the answer method that should return a double that represents the answer to the problem. The second is the toString that should return a String that represents the problem. The format should be: number…arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Programming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:CengageEBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Introduction to Classes and Objects - Part 1 (Data Structures & Algorithms #3); Author: CS Dojo;https://www.youtube.com/watch?v=8yjkWGRlUmY;License: Standard YouTube License, CC-BY