Which of the following compiles without a problem? Why? a. product.discount = 20; b. product.setDiscount(20); c. product.setPrice(50);
Q: 1. The following are the class definition for Ship, and CruiseShip. Simplied the class definition by…
A: Demonstrating the class in a simple program.The UML diagrams for Ship and CruieShip are as follows:
Q: Use the following partial class definitions to answer the questions a-c…
A: 1 a) following is true with respect to A1, A2 and A3? A2 and A3 are both subclasses of A1 A3 is a…
Q: Complete the program class Person { public: using the concept of inheritance. string profession; int…
A: Though the question is not clear, we have given complete program using inheritance concept. you can…
Q: Take this the Java Gringrots problem below turn it into a running program. where the main…
A: Solution: Given, This Java class has a main, and the following protected member functions:…
Q: It is a library service program to issue book based on ISBN and book title. Identify the code smells…
A: Consider the Borrower class.
Q: Design a class named LinearEquation for a 2x2 system of linear equations: ax + by = ecx + dy = f x =…
A: ax + by = ecx + dy = f x = (ed - bf)/(ad - bc ) y = (af - ec)/(ad-bc) The class contains:■ The…
Q: 1. Select the four (4) statements that can be inserted at line n1. public class Employee { public…
A: According to the guidelines, We are supposed to answer only one question. So I am solving the first…
Q: 1. Select the four (4) statements that can be inserted at line n1. public class Employee { public…
A: In Inheritance, a child class can access properties and methods of parent class. But a parent class…
Q: C++ Consider the following class definition: class first { public: void setX(); void print()…
A: Object oriented programming is about the creating objects which contains both data and…
Q: What is the output of executing the following code? public class Faculty extends Employee { public…
A: Hey there, I am writing the required solution based on the above given question. Please do find the…
Q: Solve within 30 minutes avoid plagiarism make it different.
A: A static method is a method that belongs to a class, but it does not belong to an instance of that…
Q: c++ Implement a BankAccount class.
A: //C++ Program: #include<iostream.h>#include<conio.h>#include<string.h>class…
Q: game racters using the concept of inheritance. Complete the program class Person { public: ( string…
A: Inheritance is almost like embedding an object into a class.
Q: Q5: Consider the following code. [14] class A { protected: double x; public: A() { coutShow(); Line…
A: a) List down the abstract and concrete classes? Ans: Note: If we do not override the pure virtual…
Q: Draw the UML diagram of the following class:
A: There are three sections in the UML class diagram: Class: The first section contains the name of the…
Q: Class Activity 1 :: Constructor Write a Java program to calculate salary of an employee in the…
A:
Q: class Vehicle { String s = "This is my vehicle" ; } class Car extends Vehicle { String s = "This is…
A: Given java code :- class Vehicle{ String s = "This is my vehicle" ;}class Car extends Vehicle{…
Q: Question 18 What is output? public abstract class People { protected String name; protected int age;…
A: Given code is public abstract class People { protected String name; protected int age; public…
Q: Which of the following lists of instance data are accessible in A3? a) x, y, z, a, b, q b) a, b, q…
A: Given classes and their inheritance :- Class A1 Class A2 derived from A1 Class A3 derived from A2
Q: 1. Select the four (4) statements that can be inserted at line n1. (3 pts. each) public class…
A: Java is an object-oriented programming language. Everything in Java is associated with classes and…
Q: Q: Write a full java application program to implement the following classes using inheritance, then…
A: Inheritance is a mechanism in which one class (derived class) acquires the property of another class…
Q: Assume Furniture is an abstract class having an abstract method called calculatePrice, The method…
A: Furniture is an abstract class and having an abstract method inside it with name calculatePrice.…
Q: Q1: Define a multiplication function inside Complex class, to multiply two complex objects. class…
A: Class complex is given which is having method for taking complex number as input. a is Real part and…
Q: Write a program that defines a class Employce with the following members as shown in the bellow UML…
A: print method will print all the information like name, id, salary
Q: Q2. Explain Constructor in detail write an example program as well.
A: CONSTRUCTOR: A constructor is basically the special method which is called just when the object of…
Q: use the following partial class definitions: public class A1 { public int x; private int y; public…
A: instance y of class A1 is private. and A derived class doesn't inherit access to private data…
Q: class xClass public: void func () ; void print () const; xClass (); xClass (int, double): private:…
A: 1) count the members does xClass have means just count the member function in the xClass- like here…
Q: c++ Implement a BankAccount class. BankAccount must have the following members: A member…
A: Code: #include<iostream>#include<stdio.h>#include<string.h> using namespace std;…
Q: What is the name of parameter used in setPrice?
A: We are given a code and in a function declaration we are asked which one is the function parameter?
Q: Exercise 1. (60 pts) Implement the class Product as presented by the following UML diagram: Product…
A: Program Explanation: Import the Scanner class Define a class for product Declare the instance…
Q: A1. Find the output of the following code in order. public class Faculty extends Employee ( public…
A: Given: public class Faculty extends Employee{ public static void main(String[] args) {…
Q: Java is the subject Add appropriate code segment for the given below code. Write the instantiation…
A: Here I ahve created the class named person with 3 data members. Next, I have created the main…
Q: For the following questions, refer to the following UML Diagram describing the Cow class. (Note: Due…
A: Solution: Given,
Q: Given the following diagram: 1 Customer Account • Account class is having 2 attributes: int id and…
A: Program a. class Account { privatedouble balance; privateint id; // constructor public…
Q: 3. Consider the following cl- definition and output the resu public class Children (String name; int…
A: // A Java program to demonstrate that non-method // members are accessed according to reference //…
Q: Add a constructor for Animal class shown. The constructor should pass in a string parameter named…
A: Class constructor : Constructor is a special method of the class. The name of the constructor is…
Q: Given the following partial class definition: public class A1 { public int x; private int y;…
A: Subclass: A class is said to be a subclass of another class if it is derived from that class. For…
Q: 1. Complete the partial declaration of Class Car: public class Car { // declare three private…
A: public class Car { //declaring private instance variables private String color; private String…
Q: QUESTION 3 Identify class name, attributes, operations, associations and create a UML clas diagram…
A: check further details for the answer :
Q: (b) The class diagram below shows the relation of three classes of a program. The class Employee is…
A: I have implemented the given requirements as per the specification. The code is as follows:…
Q: A1. Find the output of the following code in order. public class Faculty extends Employee ( E public…
A: One can use any one of the java compilers such as eclipse, Netbeans, or JDK in order to execute the…
Q: Given the declaration class myClass { public: void print(); private: int x; }; myClass AA;…
A: The code is in the C++ programming language and it is an object-oriented programming language.…
Q: Lab 8.1 Declare Card subclasses Consider using the following Card dass. public class Card private…
A: The code for the three classes are given below: public class Card{ private String name; public…
Q: Java class Person for dealing with persons.
A: Given : Write a Java class Person for dealing with persons
Q: r class contains non static members, then the class name must be modified by the keyword: Final…
A: the answer is an static
Q: Question 3 What problems might the following nested class declaration have? class Ribs { private:…
A: The question is to find the problem using the nested class.
Q: I just receive one answerfrom bartleby, however there are no output C++ Programming problem:…
A: I have done everything necessary for one derived class till addition of same currency rest of the…
Q: QUESTION 27 Given the following code, find the compile error (Choose all that apply). public class…
A: Q.27.Errors in the given Java program has been identified and the correct answers are provided…
Q: Consider the following UML class diagram for the Movie Ticketing System. You are required to create…
A: A class is the fundamental unit in object oriented programming. An instance of a class is an object.…
2- Consider the following program:
public class Product
{ private int price;
public void setPrice(int theprice)
{
price = thePrice;
}}
public class SpecialProduct extends Item
{ private int discount;
public void setDiscount(int theDiscount)
{
discount = theDiscount;
}}
public class Main{
public static void main(String[]args){
SpecialProduct product = new SpecialProduct();
}}
Which of the following compiles without a problem? Why?
a. product.discount = 20;
b. product.setDiscount(20);
c. product.setPrice(50);
Step by step
Solved in 2 steps
- Q2: Consider the following statements: public class YClass { private int a; private int b; public void one() { } public void two(int x, int y); { } public YClass() { } } class XClass extends YClass { private int z; public void one() { } public XClass() { } } YClass yObject; XClass xObject; Write the definition of the default constructor of YClass so that the instance variables of YClass are initialized to 0. Write the definition of the default constructor of XClass so that the instance variables of XClass are initialized to 0. Write the definition of the method two of YClass so that the instance variable a is initialized to the value of the first parameter of two and the instance variable b is initialized to the value of the second parameter of two. please I want solution :(Complete the missing programming steps correctly:1. class Base {public void Print() {System.out.println("Base");}}class Derived_______ Base {public void Print() {i. System.out.println("Derived");}}class Main{public static void DoPrint( Base o ) {____________}public static void main(String[] args) {Base x = new Base();Base y = new Derived();___________________DoPrint(x);DoPrint(y);DoPrint(z);} }Output: BaseDerivedDerived2. Consider the following example code and generate the output. Give your explanation aboutgenerated output.class Base {public void foo() { System.out.println("Base"); }}class Derived extends Base {private void foo() { System.out.println("Derived"); }}public class Main {public static void main(String args[]) {Base b = new Derived();b.foo();}}3. Look at the below programming code and complete the missing parts to generate the givenoutput. Output: “Interface Method Implemented”interface Pet{_____________}class Dog implements Pet{public void…8.. I need a program statement to create an object of the class Auto with a model of "Java" with a model year of 2021. public class Auto { String make="Unknown"; String model = "Unknown": int year = 0; float price = 0.0; public Auto0 { } public Auto(String given Model, int model Year) { model = givenModel; year = model Year, } public String getModelo { retum model: } public void setModel(String given Model) { model = givenModel; } public int gerYear { retum year }
- Write a program that does the following: 1-Define two classes Teacher and Department. Each Teacher has a department object as follow: [3 points] class Department{ int dno; char *name; //add data member to count number of departments automatically public: //add required methods here //define print function that prints all details of department. Note that print function is NOT function member of class Department }; class Teacher{ const int SSN; char *name; Department d; public: //add all required methods //define print function that prints all details of Teacher. Note that print function is NOT function member of class Teacher } 2-inside main do the following: a) create array of 5 Teachers. add all required details for each object inside a loop.(do NOT use cin>>) b)use print function for department and use print function for student. c)define and use a function FindTeachers that takes the array of Teachers and name of department. Then the function returns a list of all Teachers…The class diagram below shows an Order class that "has a" Customer and zero or more Items. Order class should contain private Customer m_cust; private ArrayList<Item> m_items; public Order(Customer cus t) public void additem(Item i) public String toString() Item class should contain private String m_desc private int m_qty private double m_price public Item(String des c, double price, int qty) public String toString() Customer class should contain private String m_first; private String m_last; public Customer(String first, String last) public String toString() Please create the Order, Customer, and Item classes shown above. I have provided you with a read-only Main class that you can use to test your code. When you have completed the Order, Customer, and Item classes, running the Main program should produce the following output: Order for Smith, Tom Order Items: Greeting Card: 1 at 1.5 Baseball Glove: 1 at 54.0 Notebook: 3 at 2.5 public class Main{ public static void…Java Questions - (Has 2 Parts). Based on each code, which answer out of the choices "A,B,C,D,E" is correct. Each question has one correct answer. Thank you. Part 1 - 3. Given the following code, the output is __. class Base { private int x = 5; }class Derived extends Base { x = 6; }public class Sample { public static void main(String[] args) { int x = 7; Derived d1 = new Derived(); System.out.print(d1.x); }} A. 0B. 5C. 6D. 7E. Error message Part 2 - 4. A class Animal has a subclass Mammal. Which of the following is true? A. class Animal extends Mammal { }B. class Mammal extends Animal { }C. class Animal implements Mammal { }D. class Mammal implements Animal { }E. class Mammal { Animal a1 = new Animal(); }
- 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?Question: 3 write python program ; Implement the design of the Doctor and Engineer class derived from Person class so that the following code generates the output below:class Person: def __init__(self, name, contact): self.name = name self.contact = contact def __str__(self): s = f"Name: {self.name}\nContact: {self.contact}" return s#Write your code hered = Doctor("Dr Strange", "4585632", "Neurosurgery", "DMC")d.add_patients("Dhaka Abdur Rahim", "Dhaka John Cena", "Narayanganj John Wick", "Comilla CM Punk")print("1.=========================================================")print(d)print("2.=========================================================")d.show_patient_list("Dhaka")print("3.=========================================================")d.show_patient_list("Rajshahi")print("4.=========================================================")d.add_patients("Narayanganj Naruto…Draw the UML diagram of the following class: public class Employee { String name; double salary; public Employee() { } public double getSalary() { return this.salary; } public String getName() { return this.name; } }
- Assume that you are applying “testing” and “inspection”, the two defect finding methods in the following buggy code example to find defects. Explain how “testing” and “inspection” differ in finding defects quickly and the efforts required for the example. public class Employee { private String id; private int name; private double salary; public Employee(String id,int name,double salary) { } public Employee() { } } Public class Customer { public static void main(String s[]) { Employee e1=new Employee(“10060OTU”, “S1”, 2000.50); Employee e2=new Employee(); System.out.println (“The salary of Employee S1 is”+ e1.salary); }2) Consider the following class class Department { private: string name; const long locationNo; const longdeptId; intNumOfEmployees; static intnextDeptNo; static intnextLocationNo; public: Department( ); Department(string theName, totalEmps) void Print ( ) const; } Initialize both the values of nextDeptNo and nextLocationNo to 10000 Implement the default constructor to set the name to “Unknown”, locationNo to the current value of nextLocationNo, deptId to the current value of nextDeptNo and NumOfEmployees to zero. It should also increment the value of all static attributes by 1. Implement the other constructor to set the name and NumOfEmployees to the values that are passed to the contractor. The values of the locationNo and deptId should be assigned to the current values of nextLocationNo and nextDeptNo, respectively. This constructor should also increment the values of all static attributes by 1. The print function should print all values of all attributes (regular,…Hello, I am having trouble with this homework question for my c++ course. Implement a Rational Number class with the following specifications. Data members a) numerator and denominator Functions a) Constructors: 1) default constructor 2) single parameter constructor to create numerator/1 3) dual parameter constructor to create numerator/denominator 4) Use constructor delegation across all constructors. b) Accessors and Mutators for both data members. c) Static recursive GCD function using Euclid's algorithm. d) Static LCM function for two numbers. e) Reduce function simplify a rational number. This function modifies its calling object. f) Your program should work with the supplied driver program. Notes LCM (Least Common Multiple) This function returns the smallest multiple of a and b. Step 1: Multiply a and b to find a common multiple. Step 2: Divide the common multiple by the GCD of a and b. Step 3: Return the result of Step 2. Reduce: This function reduces a fraction to…