Suppose a
// Declaration of Checkpoint class.
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 regarding the class:
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 CheckPoint 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 15 Solutions
Starting Out with C++: From Control Structures through Objects, Brief Version plus MyLab Programming with Pearson eText - Access Card Package (8th Edition)
Additional Engineering Textbook Solutions
Starting Out with C++: Early Objects (9th Edition)
Starting Out with Programming Logic and Design (5th Edition) (What's New in Computer Science)
Java How To Program (Early Objects)
Objects First with Java: A Practical Introduction Using BlueJ (6th Edition)
Java: An Introduction to Problem Solving and Programming (7th Edition)
Starting Out with Java: Early Objects (6th Edition)
- class first { public: void setX(); void print() const; protected: int y; void setY(int a); private: int x; }; Suppose that class second is derived from class first using the statement: class second: private first which members of class first are private, protected, and public in class second?arrow_forwardAnalysis 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_forwardJAVA Language Caesar Shift Question: Modify the Caesar class so that it will allow various sized shifts to be used, instead of just a shift of size 3. (Hint: Use an instance variable in the Caesar class to represent the shift, add a constructor to set it, and change the encode method to use it.) import java.util.*; public class TestCipher { public static void main(String[] args) { int shift = 7; Caesar caesar = new Caesar(); String text = "hello world"; String encryptTxt = caesar.encrypt(text); System.out.println(text + " encrypted with shift " + shift + " is " + encryptTxt); } } abstract class Cipher { public String encrypt(String s) { StringBuffer result = new StringBuffer(""); // Use a StringBuffer StringTokenizer words = new StringTokenizer(s); // Break s into its words while (words.hasMoreTokens()) { // For each word in s…arrow_forward
- using java wride a program Consider the following class definition:public class date { private int day; // from 1 to 31 private int month; // from 1 to 12 private int year; // from 2000 upwards public void advance{/*write code for method*/} // move to next day }a) Implement a constructor that initializes new objects of date class to be set to the 1st of January 2000.b) Implement setters for day, month and year.c) Implement the advance method, which moves to the next day, ensuring that all data members are updated appropriatelyarrow_forwardConsider the following class definition: (8) class base { public: void setXYZ(int a, int b, int c) ; voidsetX ( int a ) ; int getX ()const{returnx; } void setY ( int b ); intgetY()const{returny; } int mystryNum () {return ( x &*#x00A0;y - z &*#x00A0;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 class base as a public inheritance. d. Determine which members of class base are private, protected, and public in class myclass.arrow_forwardPlease help with the following: C# .NET change the main class so that the user is the one that as to put the name Write a driver class (app) that prompts for the person’s data input, instantiates an object of class HeartRates and displays the patient’s information from that object by calling the DisplayPatientRecord, method. MAIN CLASS---------------------- static void Main(string[] args) { // instance of patient record with each of the 4 parameters taking in a value HeartRates heartRate = new HeartRates("James", "Kill", 1988, 2021); heartRate.DisplayPatientRecord(); // call the method to display The Patient Record } CLASS HeartRATES------------------- class HeartRates { //class attributes private private string _First_Name; private string _Last_Name; private int _Birth_Year; private int _Current_Year; // Constructor which receives private parameters to initialize variables public HeartRates(string First_Name, string Last_Name, int Birth_Year, int Current_Year) { _First_Name =…arrow_forward
- 2. Consider the following class definitions: public class BClass } private int x; public void set(int a) } X a; { public void print() } System.out.print(x); { { public class DClass extends BClass } private int y; public void set(int a, int b) } //Postcondition: x =a; y=Db; { public void print( ) {.…} a. Write the definition of the print method of DClass that overrides it. b. Write the definition of the method set of the class DClass.arrow_forwardDesign a class that implements the basic properties of a die. Consider the definition of the following class die.(Beginner) class die { public: die(); //Default constructor //Sets the default number rolled by a die to 1 void roll(); //Function to roll a die. //This function uses a random number generator to randomly //generate a number between 1 and 6, and stores the number //in the instance variable num. int getNum() const; //Function to return the number on the top face of the die. //Returns the value of the instance variable num. private: int num; }; a) Write the definitions of the functions to implement the operations for the class die. b) Write a program that uses the class die to roll 10 dice. (Use an array of size 10 to implement 10 dice.) The program prompts the user to enter the desired sum and the number of times the dice are to be rolled. The program outputs the number of times the desired sum was rolled. Test run your program to roll the 10 dice 10000 times with the desired…arrow_forwardDetermine if this statement is true or false Take the following method, which is defined in some class: class SomeClass: SomeBaseClass{ private int override MyMethod() { //do something.... } } This is an example of run time polymorphism, as MyMethod is being redefined in the child class by the override keyword.arrow_forward
- class GradedActivity { private: double score; public: GradedActivity() { score = 0.0; } GradedActivity(double s) { score = s; } void setScore(double s) { score = s; } double getScore() { return score; } char getLetterGrade() const; }; Implement the GradedActivity class above. In this C++ assignment, create a new class Assignment which is derived from GradedActivity. It should have three private member ints for 3 different parts of an assignment score: functionality (max 50 points), efficiency (max 25 points), and style (max 25 points). Create member function set() in Assignment which takes three parameter ints and sets the member variables. It should also set its score member, which is inherited from GradedActivity, using the setScore() function, to functionality + efficiency + style. Signature: void Assignment::set(int, int, int) Create a main program which instantiates an Assignment, asks the user…arrow_forward/** NoParking models a No Parking sign */ public class NoParking { //-----------Start below here. To do: approximate lines of code = 15 // 1. Write the class so that it works as expected with the unit tester. private String startTime; private String endTime; /** Constructs a NoParking object with a default time */ public NoParking(){ startTime = "0:00"; endTime = "23:59"; } /** Sets the start time @param the start time */ public void setStartTime(String start){ startTime = start; } /** Sets the end time @param the end time */ public void setEndTime(String end){ endTime = end; } /** Reverses the times */ /** Returns the string for no parking @return the string for no parking */ } //-----------------End here. Please do not remove this…arrow_forwarduse the following partial class definitions:public class A1{public int x;private int y;public int z;…}public class A2 extends A1{public int a;private int b; …}public class A3 extends A2{private int q;…} 2) Which of the following lists of instance data are accessible in class A2?a) x, y, z, a, bb) x, y, z, ac) x, z, a, bd) z, a, be) a, barrow_forward
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrC++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning