Suppose a
class CheckPoint
{
private:
int a;
protected:
int b;
int c;
void setA(int x ) {a= x;}
public:
void setB(int y) { b = y;}
void setC(int z ) { c = z ;}
};
Answer the following questions.
A) Suppose another class, Quiz, is derived from the CheckPoint class. Here is
the first line of its declaration:
class Quiz : private CheckPoint
Indicate whether each member of the CheckPoint class is private, protected, public, or inaccessible:
a
b
c
setA
setB
setC
B) Suppose the Quiz class, derived from the CheckPoint class, is declared as
class Quiz : protected Checkpoint
Indicate whether each member of the CheckPoint class is private, protected, public, or inaccessible:
a
b
C
setA
setB
setC
C) Suppose the Quiz class, derived from the CheckPoint class, is declared as
class Quiz : public Checkpoint
Indicate whether each member of the CheckPoi nt class is private, protected, public, or inaccessible:
a
b
C
setA
setB
setC
D) Suppose the Quiz class, derived from the CheckPoint class, is declared as
class Quiz: Checkpoint
Is the CheckPoint class a private, public, or protected base class?
Want to see the full answer?
Check out a sample textbook solutionChapter 11 Solutions
Starting Out With C++: Early Objects, Student Value Edition & Myprogramminglab With Pearson Etext -- Standalone Access Card Package, 9/e
Additional Engineering Textbook Solutions
Modern Database Management (12th Edition)
Starting Out with C++ from Control Structures to Objects (8th Edition)
Java How to Program, Early Objects (11th Edition) (Deitel: How to Program)
Starting Out With Visual Basic (7th Edition)
Starting Out with Java: Early Objects (6th Edition)
Web Development and Design Foundations with HTML5 (9th Edition) (What's New in Computer Science)
- Python Programming 3. Write an Employee class that keeps data attributes for the following pieces of information:(a). Employee name(b). Employee numberNext, write a class named ProductionWorker that is a subclass of the Employee class. The ProductionWorker class should keep data attributes for the following information:(c). Shift number (an integer,such as1 for morning shift, 2 for evening shift)(d). Hourly payrateWrite the appropriate accessor and mutator methods for each class.arrow_forwardUse the following partial class definitions to answer the questions a-c public class A1 { public int x; private int y; protected int z; ... } public class A2 extends A1 { protected int a; private int b; ... } public class A3 extends A2 { private int q; ... } a) Which of the following is true with respect to A1, A2 and A3? Group of answer choices A1 is a subclass of A2 and A2 is a subclass of A3 A3 is a subclass of A2 and A2 is a subclass of A1 A1 and A2 are both subclasses of A3 A2 and A3 are both subclasses of A1 A1, A2 and A3 are all…arrow_forwardGiven the following Imagine that is attached, select that all apply A. If the Other class extends the Base class then the method guessNumber() in Other overloads the method guessNumber in Base B. If the Other class extends the Base class then the method guessNumber() in Other overrides the method guessNumber in Base C. If the Base class implements MyInterface then it must implement the guessName method or declare it abstract. D. If the Base class implements MyInterface, then every class that extends the Base class also implements MyInterface. E. If the Other class extends the Base class, and implements MyInterface then the Base class also implements MyInterface F. MyInterface can have private methods specified.arrow_forward
- Define a class for complex numbers. A complex number is a number of the form a + b*i where for our purposes, a and b are numbers of type double, and i is a number that represents the quantity √-1. Represent a complex number as two values of type double. Name the member variables real and imaginary. (The variable for the number that is multiplied by i is the one called imaginary.) Call the class Complex. Include a constructor with two parameters of type double that can be used to set the member variables of an object to any values. Include a constructor that has only a single parameter of type double; call this parameter realPart and define the constructor so that the object will be initialized to realPart + 0*i.Include a default constructor that initializes an object to 0 (that is, to 0 + 0*i).Overload all the following operators so that they correctly apply to the type Complex: ==, +, −, *, >>, and <<. You should also write a test program to test your class. Hints: To add…arrow_forwardConsider the following class definition: (8)class base{public:void setXYZ(int a, int b, int c);void setX(int a);int getX() const { return x; }void setY(int b);int getY() const { return y; }int mystryNum() { return (x * y - z * z); }void print() const;base() {}base(int a, int b, int c);protected:void setZ(int c) { z = c; }void secret();int z = 0;private:int x = 0;int y = 0;};a. Which member functions of the class base are protected?b. Which member functions of the class base are inline?c. Write the statements that derive the class myClass from classbase as a public inheritance.d. Determine which members of class base are private, protected,and public in class myClass.arrow_forwardDefine a class named Doctor whose objects are records for a clinic’s doctors. Derive this class from the class Person given in Listing 8.1. A Doctor record has the doctor’s name—defined in the class Person—a specialty as a string (for example Pediatrician, Obstetrician, General Practitioner, and so on), and an office-visit fee (use the type double). Give your class a reasonable complement of constructors and accessor methods, and an equals method as well. Write a driver program to test all yourmethods.arrow_forward
- Analysis the following class definition and answer the following question. class Student{ private int id, age; protected float mark; int getAge (int a){ return a ; } protected void setMark (float m){ mark = m; } float result(){ return mark / 2; } } What is the access specifier of the result in the above code? a. No access specifier b. private c. float d. public e. voidarrow_forward1- Create a class SchoolKid that is the base class for children ar aschool . It should have attributes of the child’s name and age ,the name of the child’s teacher ,and the greeting. It should haveappropriate accessor and mutator methods for each of the attributes. Derive a class ExaggeratingKid from schoolkid , as described above . The new class should override the accessor method for the age , reporting the actual plus 2. It also should override the accessor for the greeting ,returning the child’s greeting concatenated with the words “I am the best”.arrow_forwardA class Person is given below as your base class. Your task is to create a class Employee which will contain objects of records for an employee and derived from the class Person. Guideline for an employee record: employee's name (which is inherited from the class Person) annual salary represented (type double) year the employee started work (type int) company ID number (type String) with a format of EMPXXX (where X are numbers) Create constructors and accessor methods which you think are needed for this program, as well as another method (print) to print out all the employee’s data once you call that method. Finally, create your TestEmployee class which will contain a main method to fully test your class definition. public class Person{ private String name; public Person(){ name = "No name yet."; } public Person(String n){ name = n; } public void setName(String newName){ name = newName; } public String getName(){ return name; } public void print(){…arrow_forward
- Write a java program to create a class named shape. In this class we have three sub classes sphere, cylinder and con .Each class has two member functions named shapename () that returns the name of the shape and volume() that we will return the volume of this shape. Please define for each class the required member variables . Create these using polymorphism concepts. NO need to create a Test class, just implement the above classesarrow_forwardThe BankAccount class described below is used to represent a personal savings account with a yearly interest rate, (represented as a percentage, e.g., a 7% rate is represented by .07). The interest is applied monthly, (i.e., at the end of each month 1/12 of the interest is deposited into the account). public class BankAccount { public BankAccount(double rate) public BankAccount(double initBal, double rate) public double getBalance() public double getIntRate() public void setIntRate(double rate) public void deposit(double amount) public void withdraw(double amount) public void addMonthsInterest() private double balance; private double intRate; } Suppose a bank offers to its special customers a new type of savings account, called a “Credit Account”, that allows the customer to withdraw extra money if needed, so that the account balance is allowed to be negative at some times. These accounts award interest at the end of every month, as long as the balance is positive. If the…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_forward
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning