In the following code, which is the superclass? //A class to represent secretaries. public class Secretary extends Employee { public void takeDictation(String text) { System.out.printlin("Dictating text: " + text); } }
Q: Assuming the Employee class has a sayName method that returns the employee's name (which is Fred),…
A: => An object is a blueprint of a class in the object-oriented programming language. =>…
Q: 4. Supposed you would like to override a method with a default modifier in the superclass, which…
A: Rule for Access Modifier of overridden method : Access Modifier of the overriding method (method of…
Q: The BankAccount class models changes to the balance of a person's savings account. public class…
A: Below are the answers with code and explanation respectively:
Q: Consider the classes shown below: public class Parent { private int value = 100; public int…
A: Inheritance is a mechanism in which one object acquires all the properties and behaviors of a parent…
Q: use the following partial class definitions: public class A1 { public int x; private int y; public…
A: subclass (child) - the class that inherits from another class superclass (parent) - the class being…
Q: What is the output of the following code? Include a description of what happens. class Main {…
A: The answer to the given question: In the given java program first-class constructor is called at…
Q: What is the superclass and what is the subclass in the following line? public class Pet extends Dog
A: What is the superclass and what is the subclass in the following line? public class Pet extends…
Q: Suppose you have defined a class such as the following for use in a program:public class…
A: Suppose you have defined a class such as the following for use in a program:public class…
Q: highlight the correct answer and provide proper explanation 6. A class should take any…
A: 6. d. public class xyz <T extends Integer> 7. d error
Q: 9. Which of the following is FALSE about a subclass? A. A subclass has overridden methods from the…
A: Q19. subclass: the derived class (a class which is derived from another class) is known as the…
Q: If class Apple extends class Fruit, which of the following is also true? O Fruit is the super class…
A: Correct Answer: - All of the above For Fruit is the super class of Apple It is correct because…
Q: Find all errors in the following fragment of code. class MyClass { public:virtual myFun() = 0; {…
A: class MyClass { public:virtual myFun() = 0; { cout << "Hello"; } };
Q: 1. Create 3-member inner classes with a method a1) with one statement System.out.print(“ Hi al0");…
A: Code public class Account { //Outer class Account public class…
Q: 11. Suppose your program contains the following class definition: class myClass ( public:…
A: Your answer is given below with proper explanation.
Q: Write a SavingsAccount class for this Java program.
A: Find the following code
Q: rentiate between early binding and late binding. (Write in maximum 5 lines) [5 Marks] b. Write a…
A: Explanation: (A) Binding is the process of creating a link between a method call and method…
Q: (CLO3) Read the following Java code and answer all of the questions about it: public class Traveller…
A: Given: We are given the code in java language. The SOLID principle is being discussed in the…
Q: The BankAccount class models changes to the balance of a person's savings account. public class…
A: Below are the answers for given questions:
Q: public class Car { public void m1( { Sustem.Qut.printla("car 1"); } public void m2() { super.m1(); }…
A: answer is
Q: 4. If B is a subclass of class A. Given the following object: A a = new B0: Which of the following…
A: The correct answer option is provided below with explanation.
Q: Predict the output of the following code: public class MyClass extends Test { public static void…
A: working: The code is used to print the value of the method num() present in the classes Test and…
Q: 1. [BankAccount example] Given a superclass BankAccount and SavingsAccount subclass, what can be a…
A: We need to find the correct option. ***As per guideline first 3 questions are answered. For other…
Q: highlight the correct answer 6. A class should take any number as an argument but no other…
A: The question is to choose correct options for the given questions.
Q: ✓ Out of the following class declarations which one is/are invalid? (i) Class A { int x; }; (ii)…
A: Classes are an important concept of object-oriented programming. They are the way using which other…
Q: using System; 2 using UserNamespace; // namespace 3 4 5 namespace UserNamespace 6 + { 7 8 9 // User…
A: The given code does not have any errors. it is just giving a warning saying that the value of…
Q: An anonymous inner class can be created: a. inside an outer class that must be declared as public…
A: An anonymous inner class can be created: a inside an outer class that must be declared as public…
Q: Which of the following classes correctly inherits from the below abstract class? public abstract…
A: Abstract class is a class whose object cannot be created. To access it we must use inheritance.
Q: public class ClassA { public void methodOne(int i) { } public void methodTwo(int i) { } public…
A: We need to answer regarding given methods.
Q: 3. Create a class called BankAccount which has the following members- Private Name, id, accountType,…
A: Start. Create two object in the class BankAccount(). Declare the data members. Perform the…
Q: Which keyword is used to inherit a superclass into subclass? O a. extends O b. void O c. abstract O…
A: Actually, java is a object oriented programming language. It is a platform independent.
Q: Will the following code segment compile? If not, indicate why. Assume the code for a proper…
A: “No”, the given code does not compile without any errors.
Q: Assume the bank allows customers to open SavingAccount for which there are certain policies that…
A: Creating a class which represents a bank account with an account number and a balance that change by…
Q: Answer with True or False for the following. Explain your answers. -It is legal to write a method…
A: While overriding only occurs in an inheritance relationship, overloading can occur within the same…
Q: Given below is the code for the controlling class with constructor overloading, analyse the code and…
A: public class DriverClass{ public static void main( String[] args ){ Number N1 = new Number…
Q: Create a class, OverloadingClass, with four overloading methods, each of which has parameters,…
A: If more than one method shares the same method name with different parameter(parameter…
Q: QUESTION 9 Consider the following class definition: public class SomeClass { private int a; public…
A: The question is regarding the inheritance. Whenever we extend a class for another class, in Java,…
Q: which of the constructor that listed below will be valid to be written in the subclass? I.public BO{…
A: Required:
Q: Consider the following class: public final class Midterm{ int x =1; public Midterm(){} } What can be…
A: In the above example as we can see it is a class that is created in the public mode. and also…
Q: SuperOverride.java public class sSuperoverride { public void methodone ( (…
A: I had code everything as mentioned above and it is working perfectly fine Here is why We have…
Q: Write a subclass of Account as CheckingAccount. CheckingAccount class will have the additional…
A: Given:-
Q: Below is the class Greeter and its method, greet: public class Greeter { } public String greet() { }…
A: The program is written in Java. Check the program screenshot for the correct indentation. Please…
Q: Given uhe following code /A class to represent secretaries, public class Secrétary extends Employee…
A: Secretary inherits toString from Object
Q: 5). What will be the output of the following code? interface Test { int x = 10; } public class…
A: Answer:-(C) compilation error
Q: Which keyword is used to inherit a superclass into subclass? O a. implements O b. void c. abstract O…
A: Explaining options: a. implements this keyword is used to implement an interface i.e, abstract…
Q: 8.1 Declare Card subclasses Consider using the following Card class. public class Card { private…
A: here i am providing answer for lab 8.1 kindly split remaining questions and repost them
Q: What is the output of the following code where Student is a subclass of Person class? Person s = new…
A: The answer varies acccording to type of class
Q: A method defined within a class and whose header does NOT include the static modifier is known as…
A: A class is a collection of methods and members and there are various types of methods and let's…
Q: What would be the effect of the following code: public class Body Part { } public class Leg extends…
A: The Given question are multiple choice selected based question.
OOPs
In today's technology-driven world, computer programming skills are in high demand. The object-oriented programming (OOP) approach is very much useful while designing and maintaining software programs. Object-oriented programming (OOP) is a basic programming paradigm that almost every developer has used at some stage in their career.
Constructor
The easiest way to think of a constructor in object-oriented programming (OOP) languages is:
In the following code, which is the superclass?
//A class to represent secretaries.
public class Secretary extends Employee {
public void takeDictation(String text) {
System.out.printlin("Dictating text: " + text);
}
}
Trending now
This is a popular solution!
Step by step
Solved in 2 steps
- Given the following class definition: class employee{public: employee(); employee(string, int, double); employee(int, double); employee(string); void setData(string, int, double); void print() const; void updatePay(double); int getNumOfServiceYears() const; double getPay() const;private: string name; int numOfServiceYears; double pay;}; Create a class parttime derived from the above class that includes private members payRate and hoursWorked of type double along with a constructor and the definition of a print function that prints out all information from the base and derived class. Provide a test program that would demonstrate the working parttime class. Note: You can assume all code is stored in a single file.Please help with the following: C# .NET change the main class so that the user is the one that as to put the name in other words. Write a driver class that prompts for the person’s data input, instantiates an object of class HealtProfile and displays the patient’s information from that object by calling the DisplayHealthRecord, method. MAIN CLASS---------------------- static void Main(string[] args) { // Instance created holding 6 parameters which are field with value HealthProfile heartRate = new HealthProfile("James","Kill",1978, 79.5 ,175.5, 2021 ); heartRate.DisplayPatientRecord();// call the patient record method } CLASS HeartProfile------------------- public class HealthProfile { // attibutes which holds the following value private String _FirstName; private String _LastName; private int _BirthYear; private double _Height; private double _Weigth; private int _CurrentYear; public HealthProfile(string firstName, string lastName, int birthYear, double height, double wt, int…Please 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 =…
- 13. Fill in the blank for the toString object method of the Employee class. It returns the same thing the print method prints. public String toString() { }Design/code/test a Java program containing an abstract the class absWelcome. This class should contain: 1. A public abstract void method (you name it) that is empty 2. A public regular method (you name it) that prints "Welcome to " Next, create a subclass clsHello that extends absWelcome. This class should contain: • A public regular method (you name it) that prints "Java Programming" Finally, inside the Main class create an object (you name it) from the clsHello class. Use this new object reference to: 1. Output "Welcome to " from the abstract class 2. Output "Java Programming" from the subclass Your output should resemble that shown below >sh -c javac -classpath -type f-name '*.java') java -classpath :targe Welcome to Java ProgrammingPlease help with the following: C# .NET change the main class so that the user is the one that as to put the name a driver class that prompts for the person’s data input, instantiates an object of class HealtProfile and displays the patient’s information from that object by calling the DisplayHealthRecord, 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 = First_Name;…
- Object Oriented Programming: 213COMP, 214COMP (Feb-2022) Assignment- I [10 marks] Academic honesty: O Only pdf file accepted & student ID, will be your upload file. O Student who submit copied work will obtain a mark of zero. O Late work or attach file by email message not allowed. Q1: Write the signature for a method that has one parameter of type String, and does not return a value. Q2: Write the signature for a method that has two parameters, both of type Student, and returns an int value. Q3: Write the constructor's headers of the followings? new Student (202101156, “Ahmed"); new Address(51, "jazan university","CS&IT" ); new Grade(true, 505235600, 4.5); Q4: a) Write a class Student that define the following information: name, stid , age. b) Explain a mutators (setters) and accessors(getters) methods for each attributes(fields). c) Add three constructors: • with empty constructor. one parameter constructor (name of student) two parameters constructor (name and stid) d) Create two…java programming Robot Class : a robot has a name , located at a point with integer coordinates , faces north , east , south , or west and keeps a record of all its movements positions . The class has the following methods : A default constructor that initializes robot's name to " Unknown ” , location to ( 0,0 ) , direction to North , and travelled distance to 0 , and simulated movements to null . A constructor that given robot's name , starting location , and facing direction , Accessor methods to access all the instance variables and the simulated movements of the robot Mutator methods that change the instance variables to given values and they made the change for only suitable values . tumLeft and turn Right methods that change the direction of the robot but not the location move method that moves the robot by one unit in the direction it is facing . get Travelled Distance method that retums how many units has the robot moved .public class Father { public String name; public int age; // customer name Father(){ name=”Hassan”; age=50;} public void display(){ System.out.println(“Name:”+name); System.out.println(“Age:”+age); } } 1. Based on Figure 3, create a class named Child that inherits the Father class. Declare an instance name location (String) for class Child. 2. Define a constructor in class Child and give an appropriate initial values for the instance (name, age, location). 3. Define a method display () in class Child, execute the display ( ) method in superclass using the keyword super. Method display ( ) in class Child should print the information of name, age and location 4. Create other class named Main for the main method and create 2 objects for the 2 classes (Father and Child). Then execute the display ( ) method for Father and Child. Example of the output as in Figure 4: Father's info: Name: Josh Age: 50 Child's info: Name: Christy Age: 20 Location:…
- 1. The APCalendar class contains methods used to calculate information about a calendar. You will write twomethods of the class.public class APCalendar{/** Returns true if year is a leap year and false otherwise. */private static boolean isLeapYear(int year){ /* implementation not shown */ }/** Returns the number of leap years between year1 and year2, inclusive.* Precondition: 0 <= year1 <= year2*/public static int numberOfLeapYears(int year1, int year2){ /* to be implemented in part (a) */ }/** Returns the value representing the day of the week for the first day of year,* where 0 denotes Sunday, 1 denotes Monday, ..., and 6 denotes Saturday.*/private static int firstDayOfYear(int year){ /* implementation not shown */ }/** Returns n, where month, day, and year specify the nth day of the year.* Returns 1 for January 1 (month = 1, day = 1) of any year.* Precondition: The date represented by month, day, year is a valid date.*/private static int dayOfYear(int month, int day, int…2. Add a constructor for Animal class shown. The constructor should pass in a string parameter named "sound". 1 using System; 2 3 public class Animal 4 { 5 public string Sound { get; set; } public void Speak() { Console.Writeline("The dog says " + Sound); } 10 11 } 12 13 public class Program 14 { public static void Main() { 15 16 17 18 } 19 } A 00CSC 1302: PRINCIPLES OF COMPUTER SCIENCE II Lab 6 How to Submit Please submit your answers to the lab instructor once you have completed. Failure to submit will result in a ZERO FOR THIS LAB. NO EXCEPTIONS. The class diagram with four classes Student, Graduate, Undergraduate, and Exchange is given. Write the classes as described in the class diagram. The fields and methods for each class is given below. Student Exchange Graduate Undergraduate Student: Fields: major (String) gpa (double) creditHours (int) Methods: getGpa: returns gpa getYear: returns “freshman”, “sophomore”, “junior” or “senior” as determined by earned credit hours: Freshman: Less than 32 credit hours Sophomore: At least 32 credit hours but less than 64 credit hours Junior: At least credit hours 64 but less than 96 credit hours Senior: At least 96 credit hours Graduate:…