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 to Objects Plus MyLab Programming with Pearson eText -- Access Card Package (9th 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)
- Consider the following declarations: class xClass{public:void func();void print() const ; xClass ();xClass (int, double); private:int u;double w;};Sample Output: Program 2 and assume that the following statement is in a user program: xClass x;a. How many constructors does class xClass have?b. Write the definition of the default constructor of the class xClass so that the private member variables are initialized to 0.c. Write the definition of the constructor of the class xClass so that the private member variables u and w are initialized to the values passed in the functions.arrow_forwardTake this the Java Gringrots problem below turn it into a running program. where the main should find out how many galleons are from 100,000 knuts. : " Write a Java program using a class identified as Gringots.This Java class has a main, and the following protected member functions: Member function galleons2Sickles has an integer parameter value, and returns an integer value*17Member function sickles2galleons has an integer parameter value, and returns an integer value / 17Member function sickles2nuts has an integer parameter value, and returns an integer value*29Member function knuts2sickles has an integer parameter value, and returns an integer value/29 Member function Galleons2Knuts has an integer parameter value, and then uses member functions Galleons2Sickles and Sickles2Knuts to convert, and then returns the integer. Member function Knuts2Galleons has an integer parameter value, and then uses member functions Knuts2Sickles and Sickles2Galleons to convert, an dthen returns the…arrow_forwardWrite a java program in which Animal:Create a class Animal and Add a protected data member named id of integer type.• Add get/set methods for id data member in Animal class with public access. Also provide default constructor this should initialize id to 0.• Also provide parameterized constructor and toString method.• Add an abstract method tellAboutSelf method to Animal class with public access• Add another abstract method speak method to Animal class.Reptile, Bird, MammalNext create the three child classes which extends form Animal class.• Add a default constructor to each of the above created class. The constructor should initialize the id data member id, Reptile, Bird and Mammal, to 1, 2 and 3 respectively also it display a message “(class Name)’s default constructor”. E.g. for Bird it says “Bird’s default constructor”.• Add a parameterized constructor to each of the above created class. The constructor should initialize the id data member, Reptile, Bird and Mammal, to the…arrow_forward
- Question :- Add a statement to the classA to test whether myChar is accessible. public class ClassB { public int x = 1; int y = 2; private int z =3; } public class ClassA { public static void main(String[] args) { ClassB cb = new ClassB(); // System.out.print(cb.x); /* 1 */ // System.out.print(cb.y); /* 2 */ // System.out.print(cb.z); /* 3 */ } }arrow_forwardExamine the following code and select the correct statements (choose all possibleoptions): class Bottle {Bottle() {}Bottle(WaterBottle w) {}}class WaterBottle extends Bottle {WaterBottle() { }WaterBottle(Bottle w) { } } a) The class Bottle defines two overloaded constructors.b) The class WaterBottle defines two overloaded constructors.c) The class compiles successfully—a base class can use reference variables of its derived class as method parameters.d) Bottle and WaterBottle cause syntax errors.e) The class compiles successfully - A derived class can use reference variables of its base class as method parameters.f) A base class can’t pass reference variables of its defined class, as method parameters in constructors.arrow_forwardSuppose a program has the following class declarat ion:class CheckPoint{private:i nt a;protected:i nt b;i nt 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 CheckPoi nt class. Here isthe first line of its declaration:class Quiz : private CheckPoi nt 792 Chapte r 11 More about Classes and Object-Orien ted ProgrammingIndicate whether each member of the CheckPoi nt class is private , protec te d,pub 1 i c, or inaccessible:abCsetAsetBsetCB) Suppose the Quiz class, derived from the CheckPoi nt class, is declared asclass Quiz : protec te d Checkpoi ntIndicate whether each member of the CheckPoi nt class is privat e, protec te d,pub 1 i c, or inaccessible:abCsetAsetBsetCC) Suppose the Quiz class, derived from the CheckPoi nt class, is declared asclass Quiz : public CheckpointIndicate whether each member of the CheckPoi nt class is private, protected ,pub 1 i c, or…arrow_forward
- Write a class Distance which has two private data members (int feet,float inches). The class has three constructors which are having no parameter - values of both feet and inches are assigned zero. having two numbers as parameters - the two numbers are assigned as feet and inches respectively. having one number as parameter - both feet and inches are assigned that number. Provide getters and setters for data members. Now write a main class which demonstrate the functionality of above class by calling all constructors, setters & getters. Create 1 object using default constructor, and use setters to set values, then getters to print values. Create a second object using constructor having two parameters, provide values, then print values on screen. Create third object by using third constructor having one parameter, after that print values on screen.arrow_forwardPython 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_forwardFOR JAVA Implement the following classes / abstract classes below. Monster abstract class which has health point (int), damage point (int), name (String), resistance rate (int) fields and following methods. – A constructor that takes the name as a parameter and sets the health and damage points to random numbers between 10 and 100. – isDead() method which returns true if hp is less than or equal to 0, and false otherwise. – fight() method which prints the applied damage after resistance (see below). WaterMonster class whose resistance rate is %20. For example, if the damage of an instance of this class is 100, the fight method should print 80. FireMonster class whose resistance rate is %10. SlicingMonster class whose resistance rate is %5.arrow_forward
- Consider the following class: public class theClass { private double value; private string str; public static int count; public theClass () { } public theClass (double d, int, x, String s) { } public void print() { } public static void incrementCount() { } } a) How many members do class theClass have? b) Compare the purpose of the two constructors. c) Use the reference this to write the definition of a method print( )to output the value of the instance data members separated by commas. d) Write a statement to create an object myClass of the class theClass and initialise the instance variables to 5, 10.75 and the string Class. e) Write a definition (heading) for a copy constructor for the class.arrow_forwardWrite a java program to create a class Employee which contains member variables as name (String object)empid (Integer object)salary (Float object)age (Integer object)Define a default as well as a parameterized constructor to initialize member variables with default and specified values respectively. Define and overload a method search as defined below boolean search (Employee e[ ], String name) To search an employee with name in an array of employee objects, if found return true, else false.boolean search (Employee e[ ], Integer empid) To search an employee with the empid in an array of employee objects, if found return true, else false.Also define another method to get the name of employee having highest salary in a set of employees. String getHighestSalary(Employee e[ ]) To return the name of the employee with highest salary in an array of employee objects.Input: At least 3 employee details like name, empid, salary and age.Name of employee to searchId of employee to searchOutput:…arrow_forwardURGENT FOR JAVA Implement the following classes / abstract classes below. Monster abstract class which has health point (int), damage point (int), name (String), resistance rate (int) fields and following methods. – A constructor that takes the name as a parameter and sets the health and damage points to random numbers between 10 and 100. – isDead() method which returns true if hp is less than or equal to 0, and false otherwise. – fight() method which prints the applied damage after resistance (see below). WaterMonster class whose resistance rate is %20. For example, if the damage of an instance of this class is 100, the fight method should print 80. FireMonster class whose resistance rate is %10. SlicingMonster class whose resistance rate is %5.arrow_forward
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning