Consider the following classes: public class AA{ public int foo(int x) { return x-1; } } public class BB extends AA{ public int foo(int x){ return x + super.foo(2*x); }
Q: Does any object of type tiger have an attribute called age? yes or no
A: From the Above code, lets first try to make some conclusions: Here, since we have used extend…
Q: Cpp language. class Employee { private: string Eid string Ename; static deptno; 1: Define a…
A: It is defined as a direct descendant of C programming language with additional features such as type…
Q: A Barbershop Quartet is a group of four singers: a lead, a tenor, a bass, and a baritone. These…
A: Here i have answered in step 2.
Q: A Java program to demonstrate use of Comparable
A: Name.java public class Name implements Comparable<Name> { private String first; private String…
Q: 4. Consider the following classes: public class Animal { public Animal(String itsNane) { name public…
A: NOTE : Answering only first 3 sub parts as per the guidelines. This is a java question. In this…
Q: 1 Description of the Program In this assignment, you will make two classes, FullTime Employee and…
A: As per the given question, given the Employee class, we need to implement FullTimeEmployee,…
Q: A Barbershop Quartet is a group of four singers: a lead, a tenor, a bass, and a baritone. These…
A: Explanation on Concepts: HAS-A Relationship: It defines composition. In others words, a set of…
Q: Implement the below UML diagram into Java code Note that Employee is an Abstract class and have…
A: Solution: Given,
Q: Answer By True or False , JAVA LANGUAGE A Java interface can contain only constants and abstract…
A: Object oriented programming also abbreviated as OOPS as a programming pattern based on the concept…
Q: class Fraction private int num, denom; public Fraction(int num, int denom) (/code elided"/> public…
A: A fraction is a ratio of two values. The fraction has the form a / b where a is called the…
Q: a) How many members do class theClass have? b) Compare the purpose of the two constructors. c) Use…
A: A class is a blueprint for an object. A class can have instance variables and methods which are…
Q: Identify the subclass and superclass. Create other class named Triangle that inherits the properties…
A: A class that is derived from another class is called a subclass. The class from which the subclass…
Q: *a Given the following declaration of the class Foo, are the following valid or invalid ways to…
A: a) Foo f; This is the correct way declaration as this will call the default constructor the given…
Q: You must modify the class Owner provided below, so that objects of this class can hold objects of…
A: Note: The code does not have any main method so there is no programming running output, only the…
Q: nstructions: Implement the Java class Customer by following the UML class diagram provided below.…
A: All the members variables are made private.Getters and setters can be used to get and set value of…
Q: Consider the following code segment and answer questions 14 and 15. class Point { public: Point…
A: A constructor is a unique method or function used in object-oriented programming that is invoked…
Q: Draw a UML class diagram for the following code: public class ArrayQueue { private Object[]…
A: It provides an overview of the system's object-oriented design by illustrating the classes, their…
Q: #include class A { private: class B { public: B() { x = 1; } int x;…
A: Note: - As per our honor code we only answer 3 subparts. Please repost the question accordingly.…
Q: PROGRAMMING LANGUAGE: JAVA SUBJECT: ADVANCED OOP WITH JAVA QUESTION NO 1: Make an abstract…
A: Abstract class: In the Java programming language, an Abstract class is declared using the abstract…
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: Consider the following class Time, which represents a time using three ints for hour, minute and…
A: #include <iostream>using namespace std; class Time { private: int hour; int min; int sec;…
Q: What is the output of the following code snippet? new Student(); = new Student(345, 3.5); Student…
A: 1. B. 0 3.5 2. D 345 345
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: Given the following Date class public class Date { private int year; private int month; private int…
A: Answer: date d=new Date(2020,20,9);
Q: Find the error in the following code
A: Please upvote. I am providing you the correct answer. You can never, in no context, change an…
Q: Section 9.2: Interacting with the Superclass 4. Explain the difference between the this keyword and…
A: Difference between this and super keyward: Keyword Description Usage this Refers to the…
Q: (i) Class A { int x; }; (ii) Class B { } (iii) Public class A { } (iv) Object A { int x; };
A: As we know while creating any class its basic syntax is : Class A { private: int y;…
Q: USING C++ Implement the Rectangle class below: *******RECTANGLE CLASS******* class Rectangle {…
A: #include <iostream>using namespace std;class Rectangle{ private: double width; double…
Q: Given the following code: } public class Foo { public void barl () { public abstract void bar2 ();…
A: abstract method Only applicable in an abstract class, an abstract method lacks a body. The subclass…
Q: Explain the following Java Inheritance code in details. public class Point extends Object {…
A: Inheritance is the Java feature which allows a class to inherit the protected and public data…
Q: Consider the definition of the following class: class Counter{ private: int x; double y;…
A: #include<iostream> using namespace std; class Counter{ private : int x; double y; public:…
Q: Analysis the following class definition and answer the following question. class Student{…
A: class Student{ private int id, age; protected float mark;…
Q: Identify the constructor for the following class class Teacher { int id; String name; O a. Teacher)…
A: Option (a) is the correct option.
Q: What is the value of numltems after the below code is executed? Iten jar new Iten(); Iten ball ne…
A: Here the variable numItems is a static variable. Thus it will be initialized only once and will be…
Q: Complete the partial declaration of Class Car: public class Car { // declare three…
A: this keyword takes value from current object of instance variables. A setter method is always of…
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: 1. An abstract class called Pet is defined below: public abstract class Pet { private String id;…
A: Dear Student, As no programming language is mentioned I am assuming it to be Java. The Cat class…
Q: The following is someone’s definition for the Checking class. public class Checking {…
A: Below i have highlighted the logical errors in BOLD and commented the wrong statement. Correct…
Q: 1) Draw a class diagram depicting the below code. class Doctor { void Doctor Details () {…
A: According to our guidelines , i solve first one because second is not the part of first:…
Q: class ProgLang String pName; // represent its name protected int pCode; // represent its Code…
A: Answer is below:
Q: ivate int x; blic int y; otected int z; blic A() private int x; public int y; protected int z;…
A: The answer is below:
Q: Which of the following compiles without a problem? Why? a. product.discount = 20; b.…
A: private members are not accessible outside the class
Q: Differentiate between static and instance class members. Explain with proper example when you should…
A: Instance variables Static (class) variables Instance variables are declared in a class, but…
Q: class Car { } public Car() { } What happens if you try to run new Car();
A: Answer:
Q: The class Store has to implement the following functionalities 1 public class Store 2 { 3 4…
A: In this example, the Store the class has two fields: shopName and stock. The shopName the field is…
Step by step
Solved in 4 steps with 4 images
- [CLO-4] Consider the following classes: package p1; public class Child extends Parent{ private int a; package p1; public Child(){ public class Parent{ System.out.println("In Child"); } private int x; public int y; public Child(int a){ protected int z; int w; this.a = a; System.out.print("In Child with parameter"); } public Parent() { System.out.println("In Parent"); public void print() { } // 1 public void print() { System.out.print(a); // 2 System.out.print(x + +y); } System.out.print(x); // 3 }// end class System.out.print(z); // 4 System.out.print(w); JULL IU 11 12 13 14 In the method print() of the child class. Which statement is illegal ?? O // 2 System.out.print (x); // 2 System.out.print (x); // 4 System.out.print (w); // 2 System.out.print (x); // 3 System.out.print (z); // 4 System.out.print (w); // 2 System.out.print (x); // 3 System.out.print (z); O All statements are illegal. // 1 System.out.print (a); // 2 System.out.print (x); O O ال-ال- } }// end class CamScannerPartial Question 3 Consider: class A { } public void doA() { } class B extends A { } public void doB () { } Which of the following are allowed? B x = new B(); x.doB(); A x = new A(); x.doA(); A x = new A(); x.doB(); B x = new B(); x.doA();6. Given: class Pet { public: virtual void eat() { cout eat(); } What is the result of compiling and running the above program? m. The program compiles and crashes when it runs. i. The program compiles and runs, printing "Pet::eat" j. The program compiles and runs, printing "Cat::eat" The program compiles and runs to completion without printing anything. n. o. None of the above. k. The program fails to compile because the method eat is not marked virtual in Cat. I. The program fails to compile for some other reason.
- use 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, bModify and rewrite the Food class to an abstract class, so that no instance of Food class can be createdclass IndexItem { public: virtual int count() = 0; virtual void display()= 0; };class Book : public IndexItem { private: string title; string author; public: Book(string title, string author): title(title), author(author){} virtual int count(){ return 1; } virtual void display(){ /* YOU DO NOT NEED TO IMPLEMENT THIS FUNCTION */ } };class Category: public IndexItem { private: /* fill in the private member variables for the Category class below */ ? int count; public: Category(string name, string code): name(name), code(code){} /* Implement the count function below. Consider the use of the function as depicted in main() */ ? /* Implement the add function which fills the category with contents below. Consider the use of the function as depicted in main() */ ? virtualvoiddisplay(){ /* YOU DO NOT NEED TO IMPLEMENT THIS FUNCTION */ } };
- Consider the following classes: public class Animal { public Animal(String itsName) { name = itsName; } public void setName(String itsName) { name = itsName; } public String getName() { return name; } private String name; } public class Dog extends Animal { public Dog(String itsName) { super(itsName + “Dog”); sound = “Bark!”; } public void setSound(String itsSound) { sound = itsSound; } public String getSound() { return (getName(0) + sound); } public String getName(int choice) { if(choice > 0) return super.getName(); else return “AnyDog”; } public String getName() { return super.getName() + “OK”; } private String sound; } In addition, the following lines of code has been placed in a main class public static void main(String[] args) { Animal a1 = new Animal(“Tweety”); Animal a2 = new Dog(“Rover”); Dog d1 = new Dog(“Spot”); . . . . } Give the values of the following expressions. If an expression is erroneous,…Consider the following classes Package p1; Package p2; Package p2; Package p1; public class C1{ public class C2{ public class C3 { public class C4 extends C3{ public double age3; private String name; protected double salary; String major; void find(X void serach(){ void claculate(){ void compute(){ a) What are the methods that can access the variable age. b) What are the methods that can access the variable name. c) What are the methods that can access the variable salary. d) What are the methods that can access the variable majorpublic class Cylinder { public void smoothen() { } } } public abstract class Vessel implements Steerable { private Engine e; } System.out.println("Smoothening.."); public Engine getEngine() { return e; } public void setEngine (Engine e) { this.e = e; } public abstract void turnOn(); public class Engine { private Cylinder [] y; private int cyls = 1; static final int maxCylinders = 12; public void addCylinder (Cylinder y) { if (cylsWrite classes for representing game state and movepublic abstract class Shape { public Shape() { } public abstract double area() ; public String who() { return "Shape" ; } } public class Circle extends Shape { private int radius ; public Circle( int r ) { radius = r ; } @Override public double area() { return Math.PI * radius * radius ; } } public class Square extends Shape { private int _sideLength ; public Square( int sideLength ) { /* TODO question 45 */ } @Override public double area() { return _sideLength * _sideLength ; } } Implement the Square constructor, and make sure it throws an exception when the input parameter is not a valid length. The input parameter must be positive to be considered valid.2) What will be the output of the following code? abstract class X { int b; abstract void print(); } class Y extends X { int a; void print() { System.out.println(a); } } class Test_Questions { public static void main(String args[]) { X obj obj.b = 6; obj.print(); } } = new Y(); a. O b. 6 c. Compilation error d. Garbage value