The access specifier which can be used to access variables from subclass of other package is O a. Private O b. Protected O c. Default d. No modifier
Q: If myClass has a constructor with a parameter of type String, select the other constructor that be…
A: The answer is given in the below step with an example.
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: Take a look at the class declaration below: package p1; class Test8{ int i; package p2; import…
A: Only variable l is accessible in Test9 directly by creating a reference of Test8. Reason: variable l…
Q: What is the output of the following code where Student is a subclass of Person class? Person s =…
A: The instanceof operator is used to test whether the object is an instance of the specified type…
Q: Given: abstract class A{ int a; int b; } class B extends A{ int a; } O cannot make class A abstract…
A: Answer 1: A- cannot make class A abstract Abstract classes can not be instantiated.
Q: Assume that you write a class Student that does not have a declared superclass. You do not write a…
A: Solution) String "s" will have the string Student@address
Q: If class A inherits class B and class C as "class A: private class B, public class C {// class…
A: This question comes from Object Oriented Programming which is a paper of Computer Engineering. Let's…
Q: 5. How many parameters must be passed if only the following prototype is given to a constructor?…
A: Question 5. How many parameters must be passed if only the following prototype is given to a…
Q: 1. Write a class "Ball" which extends the class disk. It has deltax and deltay attributes. 2. Write…
A: I have provided the answer based on Java Programming. Detailed comments are included for a better…
Q: This keyword is to declare a user-defined package. Choose. Choose.. public import This is the most…
A: I have given an answer in step 2.
Q: abstract class A{ int a; int b; abstract void methodA(); class B extends A{ int a; void methodA(){…
A: Objective: Two questions are given on java inheritance and abstract class or method characteristics.…
Q: Subject : object Orieted Programming Q: Find the error in the following given codes and rewrite.…
A: Some key point to note:- In an interface, you can only method declaration not the definition (body)…
Q: Please write the following program in JAVA! Thanks, refer to photos.
A: Program: //Filename: “XXXX_TestWorker.java” import java.util.*; public class XXXX_TestWorker {…
Q: PLZ help with the following IN JAVA When defining an inner class to be a helper class for an outer…
A: When defining an inner class to be a helper class for an outer class, the inner classes access…
Q: Overloading is achieved when two or more methods in the same class have the same
A: Method overloading or function overloading means creating methods with same name but different…
Q: 1. LockADT - Show the interface and all abstract methods LockDataStructureClass - Show the following…
A: PROGRAM CODE: // import the required librariesimport java.util.*;import java.lang.*;import…
Q: Write a lambda or method reference for each of the following tasks: a) Write a lambda that can be…
A: As per Bartleby guidelines “Since you have posted a question with multiple sub-parts, we will solve…
Q: Java always provides a default constructor. That is, a constructor that can be caller with no…
A: We have to explain whether this statement is true or false. Java always provides a default…
Q: In Java, which condition occurs when the same object appears as both an input and output parameter?
A: According to the question, we need to identify that: In Java, which condition occurs when the same…
Q: Inheritance through an extended (derirved) class supports which of the following concepts? a)…
A: The idea of a legacy in Programming language is that you can create new classrooms built on…
Q: IS public interface A { public int methodl () { return 1; } public interface B { } default int…
A: Answer: 4
Q: What is true about Class.getInstance()? a) Class.getInstance calls the constructor b)…
A: Answer d) Class.getInstance creates object if class does not have any constructor
Q: The interface Speaker is describe below. public interface Speaker{ public void speak(); public void…
A: // Speaker.java // Speaker Interface public interface Speaker { public void speak(); public…
Q: Assignment: Write the class XXXX_Worker with constructors, accessors, mutuators, and a toString…
A: create XXXX_Worker class with instance data members as Worker Name and Number.declare constructors,…
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: Consider, the code: public class MyClass { public MyClass() { // some code } // some more code } To…
A: Question 1 In order to initiate MyClass , you need to create create an object for that which is…
Q: To overload constructors, we write multiple constructor declarations with the same signatures. True…
A: Constructor overloading means, writing multiple constructor with different signature, you cannt…
Q: ou need to write the complete code as mentioned below: i) The main class with necessary codes.…
A: Summary:In this question, we need to create a superclass, subclass, and test class to test the…
Q: Q1.) Write a Review class that has: • These private data members: • string user: ID of the user…
A:
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: Write a Java class Student that is fully encapsulated and has a private data member name. The class…
A: class Student { // Declare name variable to store Name into it private String name;…
Q: You cannot instantiate an interface but you can do so to an abstract class. True False
A: Abstract Class: An abstract class is a class that is declared abstract. It may or may not contain…
Q: hello! can you help debug my program? it's in Java! here are the errors I'm getting: line 189:…
A: Debugged code is given below: Code: package zoo;abstract class Animal { private String name;…
Q: 1 Lab 2 (ADTS) 1. LockADT – Show the interface and all abstract methods LockDataStructureClass –…
A: ANSWER:-
Q: class Test4 { int i; Test4 (int m){ i = m; class Test5 extends Test4{ private int j; Il add a…
A: The program illustrates the inheritance, polymorphism (overloading), and super keyword. Test4 is a…
Q: A. Write the classes as shown in the following class diagram. Movable is an interface and…
A: Movable.java public interface Movable { void moveUP(); void moveDown(); void…
Q: A. Write the classes as shown in the following class diagram. Movable is an interface and…
A: Movable.java public interface Movable { void moveUP(); void moveDown(); void moveLeft();…
Q: write a java programme: Vehicle class: First create an abstract Vehicle class that contains code…
A: To write a java program for given scenario which hold methods like class and interfaces. An…
Q: If you assign a new instance of a subclass object to a super-class variable without casting, what…
A: Let us see the answer,
Q: In java ,A subclass constructor cannot catch exceptions thrown by its superclass constructor. Is…
A: Given: In java ,A subclass constructor cannot catch exceptions thrown by its superclass constructor.…
Q: Dilowing code shippet oI Object public interface Measurer { double measure (_?. anobject); Complete…
A: 11. Consider the following code snopet of a function object public interface Measurer{ double…
Q: What is the concept of binding? Differentiate between early binding and late binding. (Write in…
A: Solution : Binding refers to the process of converting identifiers (such as variable and performance…
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: A Truck can be described as having a make (string), model (string), gas tank capacity (double), and…
A: Solution: Given, Truck.java class Truck{ private String make, model; private double…
Q: FOR JAVA Part I Create a Company class that has at least three properties. Part II Write…
A: we write java code: class Company { int company_id,turnover; String name,address,department,email;…
Q: An interface must meet which of these restrictions? I. It must not have any fields. II. Methods…
A: NOTE Below is the answer for the given question. Hope you understand it well. If you have any…
Q: Why the below class is showing compilation error? abstract class AbstractClass { abstract void…
A: The Above program has an Error Because
Q: When a method in a subclass overrides a method in superclass, it is still possible to call the…
A: All the code is correct. Just add a super keyword before the method. Super keyword used to…
Step by step
Solved in 3 steps
- Which of the following does NOT apply to the strategy design pattern? It can change the behavior of a class at runtime It can eliminate conditional statements It can reduce the communication overhead between objects It provides an alternative to subclassing None of aboveTest your newly created subclasses inside the same TestComputer program you previouslycreated: create two new Laptops and two new Desktops with the data of your choice. UsetoString() method to show all data fields (including the data fields in the super class and sub class)Hint: Make sure to avoid redundancy in your code – no fields implemented in the Parent Classshould be repeated/reimplemented/redefined in children. package project2;class Desktop extends Computer { private int width; private int height; public Desktop() { super(); width = height = 0; } public Desktop(String manufacturer, String diskSize, String manufacturingDate, int numberOfCores, int width, int height) { super(manufacturer, diskSize, manufacturingDate, numberOfCores); this.width = width; this.height = height; } public int getWidth() { return width; } public int getHeight() { return height; } public void setWidth(int width) {…Which one is true? A) An inner class can be declared public or private subject to the same visibility rules applied to a member of the class. B)An inner class can be declared static. A static inner class can be accessed using the outer class name. A static inner class cannot access non-static members of the outer class. C)An inner class supports the work of its containing outer class and is compiled into a class named OuterClassName$InnerClassName.class. D)Inner classes can make programs simple and concise.
- The xxx_Pet classA Pet has a:– Name• Include an instance variable• Getters and setters for an instance variable• A toString method which returns a String containing the pet name Abstract methods: speak() and move()The subclassesWrite a dog, cat, snake subclasses with proper instant variables and methodsWrite a class xxx_TestPet which will1- Create a dog, a snake, and a cat objectsSample OutputPet Fido is a dog, weighing 45 poundsFido says woofrun Fido runPet Sam is a snake, 30 inches longSam says hissslither Sam slitherPet Hershey is a cat, with Long hairHershey says Meowprance Hershey prance2- Print just the weight of the Dog, the length of the Snake and the hair length of theCat as shown belowFido weighs 45 poundsSam has length 30 inchesHershey has Long hair 3- Store the objects in an Array of Pet objects and print the information belowPet D1 is a dog, weighing 55 poundswoofrunPet S1 is a snake, 30 inches longhissslitherPet C1 is a cat, with Long hairmeowprancePet D2 is a dog,…1)a pytest can be implemented as a method in a class a ) true b) false 2) a rule of thumb is that there should be lots and lots of unit tests, many integration tests and relatively few end-to-end tests a) true b) False 3) a source code control library allows programmers to review and restore any change to the product being developed a) true b) false 4) cloning a git repository involves a) mounting the repository as a remote file device b) copying the entire repository to my workstation c) Forking the repository c) contributing to the repository 5) compared to integration and end-to-end tests, unit tests, are usually small and run quickly a) true b) falseMake a data type called Version that reflects the version number of a piece of software, like 115.1.1, 115.10.1, or 115.10.2. Implement the Comparable interface to make 115.1.1 less than 115.10.1, 115.1.1 less than 115.10.1, etc.
- Use the code provided copied to a new file named compulsory_task_1.py: 1. Add another method in the Course class that prints the head office location: Woodstock, Cape Town2. Create a subclass of the Course class named OOPCourse3. Create a constructor that initialises the following attributes and assigns these values: --- "description" with a value "OOP Fundamentals" --- "trainer" with a value "Mr Anon A. Mouse"4. Create a method in the subclass named "trainer_details" that prints what the course is about and the name of the trainer by using the description and trainer attributes.5. Create a method in the subclass named "show_course_id" that prints the ID number of the course: #123456. Create an object of the subclass called course_1 and call the following methods contact_details trainer_details show_course_id These methods should all print out the correct information to the terminal On a side note, this task covers single inheritance. multiple inheritance is also…Choose the correct option 4)Choose the correct option?#include<iostream>using namespace std;class Base {};class Derived: public Base {};int main(){Base *bp = new Derived;Derived *dp = new Base;}a. No Compiler Errorb.Compiler Error in line “Base *bp = new Derived;”c. Compiler Error in line ” Derived *dp = new Base;”d. Runtime Error 5)When the inheritance is private, the private methods in base class are __________ in the derived class (inC++).a. Inaccessibleb.. Accessiblec.. Protectedd. PublicThe Hal9000 has one constructor which takes a String parameter of a name of the crew member it is interacting with. It has methods: public String getName() which gets the name public void setName(String newName) which sets a new name public String greet() which returns a string consisting of "Greetings, name" where name is the name supplied in the constructor. public String reportStatus() which returns a string consisting of "All systems are operating normally, name" where name is the name supplied in the constructor. public String execute(String command) which returns a string consisting of "I am sorry, name. I can't " + command where name is the name supplied in the constructor and command is the parameter. Supply Javadoc for the constructor and all the methods
- The Hal9000 has one constructor which takes a String parameter of a name of the crew member it is interacting with. It has methods: public String getName() which gets the name public void setName(String newName) which sets a new name public String greet() which returns a string consisting of "Greetings, name" where name is the name supplied in the constructor. public String reportStatus() which returns a string consisting of "All systems are operating normally, name" where name is the name supplied in the constructor. public String execute(String command) which returns a string consisting of "I am sorry, name. I can't " + command where name is the name supplied in the constructor and command is the parameter.1. Creating overloaded methods with identical sets of parameters and different return types result in compilation errors. Overloaded methods must have different sets of parameters- also known as signatures. Is it True or False? 2. Attempting to modify a final instance variable after it is initialized is a compilation error. Is it True or False? 3. A subclass can effect state changes in superclass private members only through public, protected methods provided in the superclass and inherited into the subclass. Is it True or False?Consider the following class definitions public class SampleClass{ public String greet() {return "Greetings";} } public class SubClass extends SampleClass{ public string greet() {return "Hello";} } public class AnotherClass{ public String greet() {return "Hi";} } What can be said about the following code fragment? public class Driver { public static void main(String[] args){ Object p =new SampleClass(); System.out.println((AnotherClass).p),greet()); } } a. The above code compiles but causes runtime error. b. The above code has no issues. It compiles and runs. c. The above code causes compiler error.