Indicate true or false for the following statements:
a. A protected datum or method can be accessed by any class in the same package.
b. A protected datum or method can be accessed by any class in different packages.
c. A protected datum or method can be accessed by its subclasses in any package.
d. A final class can have instances.
e. A final class can be extended.
f. A final method can be overridden.
Want to see the full answer?
Check out a sample textbook solutionChapter 11 Solutions
Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
Additional Engineering Textbook Solutions
Concepts Of Programming Languages
Starting Out With Visual Basic (7th Edition)
Java How to Program, Early Objects (11th Edition) (Deitel: How to Program)
C Programming Language
Java: An Introduction to Problem Solving and Programming (7th Edition)
- Answer with True or False for the following. Explain your answers.-It is legal to write a method in a class which overloads another method declared in the same.-It is legal to write a method in a superclass which overrides a method declared in a sub-class.arrow_forward5. How many parameters must be passed if only the following prototype is given to a constructor? Prototype: className(int x, int y, int z=0); a) 1 b) 2 c) 3 d) Compile time errorarrow_forwardQ2: 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 :(arrow_forward
- Write a class named Employee which implements Comparable Interface with name and salary as data fields Add a constructor with argument name and salary. Add getter and Setter for name and salary. Add CompareTo() method for the data Salary. Write a class named Manager which inherits the Employee class. Add an instance variable, named department, of type String. Add a constructor in the subclass class with arguments name, salary, department and a toString() method that prints the manager’s name, department, and salary [Hint: Add a toString( ) method in the super class as well] Create 3 objects of Manager with following arguments 1. (Zayed, 500), 2. ( Ahmed, 700) 3. ( Faisal, 600) Add the above 3 objects into an ArrayLIst object and Sort by Salary and Display. Create an object Employee class with (Zayed, 500,IT) and display the 1. Name 2. Salary 3. Department by using tostring() method.arrow_forward2. What will be the output of the following code? a. Compilation error in line 1 (abstract method cannot be private) b. Compilation error in line 2 (abstract class cannot have concrete method) c. Compilation error in line 3 (abstract class cannot be extended) d. Compilation error in line 4 (marks method should have public access modifiers.arrow_forwardWrite a Java operator/keyword, which can be used to check the validity of reference before attempting down-casting from superclass object to subclass reference. Given an example of it usage. (Write in maximum 5 lines) Assume you have a method expecting the superclass's object to be passed as an argument. In this case, if you give it an object of subclass rather than superclass. Is it acceptable? Why or why not? (Write in maximum 5 lines)arrow_forward
- Write a class named Employee which implements Comparable Interface with name and salary as data field. Add a constructor with argument name and salary. Add getter and Setter for name and salary. Add CompareTo() method for the data Name. Write a class named Manager which inherits the Employee class. Add an instance variable, named department, of type String. Add a constructor in the subclass class with arguments name, salary, department and a toString() method that prints the manager’s name, department, and salary [Hint: Add a toString( ) method in the super class as well] Create 3 objects of Manager with following arguments 1. (Zayed, 500), 2. ( Ahmed, 700) 3. ( Faisal, 600) Create an Array object Add the above 3 objects into an Array object and Sort by Name and Display Create an object Employee class with argument (Zayed, 500, IT) Display the 1. Name 2. Salary 3. Department by using tostring() method.arrow_forwardCan you implement the Derived Class Parameterized constructor? A solution is placed in the "solution" section to help you, but we would suggest you try to solve it on your own first. Implement the constructor Dell(String name) of the Derived Class Dell which takes a string, name. We have already implemented the Base Class Laptop with the member function getName() and a parameterized constructor. Input# Laptop name is being passed through the parameterized constructor. Output# getName() method is returing Laptop name. Sample Input# Dell dell = new Dell("Dell Inspiron"); Sample Output# "Dell Inspiron"arrow_forwardProblem 1: Complete a properly encapsulated class named Shape, which has the following: -A Boolean instance variable named is Filled . -A String instance variable named color. - A default, no-arg constructor which sets isFilledto true, and colorto “Green”. -An overloaded constructor which takes two parameters, a Boolean and a String and sets the instance variables accordingly. -An overridden toString() method, which returns a String. The String should contain: The values of the instance variables in the following format: Filled: true Color: Greenarrow_forward
- If class A is a subclass of class B, then A has access to all of B's instance variables, including private ones. True Falsearrow_forwardWrite a Java Program, Create a class with a method that prints "This is parent class" and its subclass with another method that prints "This is child class". Now, create an object for each of the class and call 1 - method of parent class by object of parent class 2 - method of child class by object of child class 3 - method of parent class by object of child class In the above example, declare the method of the parent class as private and then repeat the first two operations (You will get error in the third).arrow_forwardWhich class can access all public and protected methods and fields of its super class?arrow_forward
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning