All Matches
Solution Library
Expert Answer
Textbooks
Search Textbook questions, tutors and Books
Oops, something went wrong!
Change your search query and then try again
Toggle navigation
FREE Trial
S
Books
FREE
Tutors
Study Help
Expert Questions
Accounting
General Management
Mathematics
Finance
Organizational Behaviour
Law
Physics
Operating System
Management Leadership
Sociology
Programming
Marketing
Database
Computer Network
Economics
Textbooks Solutions
Accounting
Managerial Accounting
Management Leadership
Cost Accounting
Statistics
Business Law
Corporate Finance
Finance
Economics
Auditing
Hire a Tutor
AI Study Help
New
Search
Search
Sign In
Register
study help
computer science
starting out with java from control structures
Questions and Answers of
Starting Out With Java From Control Structures
Write the first line of a class named Employee, which implements interfaces named Payable and Listable.
True or False: A superclass has a member with package access. A class that is outside the superclass’s package but inherits from the superclass can access the member.
Write the first line of a class named Customer, which implements an interface named Relatable.
True or False: When a method is declared with the final modifier, it must be overridden in a subclass.
If an interface has fields, how are they treated?
True or False: The superclass constructor always executes before the subclass constructor.
How is an interface different from an abstract class, or any class?
True or False: An object of a superclass can access members declared in a subclass.
How is an interface similar to an abstract class?
True or False: If a subclass constructor does not explicitly call a superclass constructor, Java will not call any of the superclass’s constructors.
What is the purpose of an interface?
True or False: In a subclass, a call to the superclass constructor can only be written in the subclass constructor.
If a class is defined as abstract, what can you not do with the class?
True or False: Constructors are not inherited.
What is the purpose of an abstract class?
You can use a lambda expression to instantiate an object that __________.a. That has no constructor.b. Extends any superclass.c. Implements a functional interfaced. Does not implement an interface.
If a subclass extends a superclass with an abstract method, what must you do in the subclass?
A functional interface is an interface with __________.a. Only one abstract method.b. No abstract methods.c. Only private methods.d. No name.
What is the purpose of an abstract method?
An anonymous inner class must __________.a. Be a superclassb. Implement an interfacec. Extend a superclassd. Either b or c.
You use the __________ operator to define an anonymous inner class.a. Classb. Innerc. Newd. Anonymous
When you create a class, it automatically has a toString method and an equals method. Why?
Abstract classes cannot __________.a. Be used as superclassesb. Have abstract methodsc. Be instantiatedd. have fields
Look at the following class definition: Public class ClassD extends ClassB{ (Member Declarations . . .)}Because ClassD inherits from ClassB, is it true that ClassD does not inherit from the
Abstract methods must be __________.a. Overriddenb. Overloadedc. Deleted and replaced with real methodsd. Declared as private
What is a lambda expression?
Why is it easy to give package access to a class member by accident?
Fields in an interface are __________.a. Finalb. Staticc. Both final and staticd. Not allowed
What is a functional interface?
What is the difference between private access and package access?
When a class implements an interface, it must __________.a. Overload all of the methods listed in the interfaceb. Provide all of the nondefault methods that are listed in the interface, with the
When you instantiate an anonymous inner class, the class must do one of two things. What are they?
Why should you avoid making class members protected when possible?
This operator can be used to determine whether a reference variable references an object of a particular class.a. Isclassb. Typeofc. Instanceofd. Isinstance
What are the differences between an abstract class and an interface?
What is the difference between private members and protected members?
With this type of binding, the Java Virtual Machine determines at runtime which method to call, depending on the type of the object that a variable references.a. Staticb. Earlyc. Flexibled. Dynamic
When a class member is declared as protected, what code may access it?
All classes directly or indirectly inherit from this class.a. Objectb. Superc. Rootd. Java
How do you prevent a method from being overridden?
These superclass members are accessible to subclasses and classes in the same package.a. Privateb. Publicc. Protectedd. All of these
When does dynamic binding take place?
If a method in a subclass has the same name as a method in the superclass, but uses a different parameter list, does the subclass method overload or override the superclass method?
A method in a subclass having the same name as a method in the superclass but a different signature is an example of __________.a. Overloadingb. Overridingc. Compositiond. An error
If a method in a subclass has the same signature as a method in the superclass, does the subclass method overload or override the superclass method?
A method in a subclass that has the same signature as a method in the superclass is an example of __________.a. Overloadingb. Overridingc. Compositiond. An error
Design a class named Person with fields for holding a person’s name, address, and telephone number. Write one or more constructors and the appropriate mutator and accessor methods for the class’s
The following is an explicit call to the superclass’s default constructor.a. Default();b. Class();c. Super();d. Base();
What is the difference between overriding a superclass method and overloading a superclass method?
How can a subclass method call an overridden superclass method?
Write the first line of the definition for a Stereo class. The class should extend the SoundSystem class, and it should implement the CDplayable, TunerPlayable, and CassettePlayable interfaces.
In a subclass constructor, a call to the superclass constructor must __________.a. Appear as the very first statementb. Appear as the very last statementc. Appear between the constructor’s header
Which constructor is called first, that of the subclass or the superclass?
Under what circumstances would a subclass need to override a superclass method?
A superclass has the following abstract method: Public abstract int getValue();Write an example of a getValue method that can appear in a subclass.
This key word refers to an object’s superclass.a. Superb. Basec. Superclassd. This
Can a subclass ever directly access the private members of its superclass?
Look at the following classes: Public class Ground{ Public Ground() { System.out.println("You are on the ground."); } Public Ground(String
A superclass has the following method: Public void setValue(int v){ Value = v;}Write a statement that may appear in a subclass that calls this method, passing 10 as an argument.
Design an Essay class that extends the GradedActivity class presented in this chapter. The Essay class should determine the grade a student receives for an essay. The student’s essay score can be
A subclass does not have access to these superclass members.a. Publicb. Privatec. Protectedd. All of these
What is the difference between a protected class member and a private class member?
Look at the following classes: Public class Ground{ Public Ground() { System.out.println("You are on the ground."); }}Public class Sky extends Ground{ Public
Write the statement that calls a superclass constructor and passes the arguments x, y, and z.
This key word indicates that a class inherits from another class.a. Derivedb. Specializedc. Basedd. Extends
What is the superclass and what is the subclass in the following line? Public class Pet extends Dog
In an inheritance relationship, this is the specialized class.a. Superclassb. Master classc. Subclassd. Parent class
A program uses two classes: Animal and Dog. Which class is the superclass and which is the subclass?
Look at the following class declarations and answer the questions that follow them: public class Shape{ Private double area; Public void setArea(double a) { Area =
Look at the following code, which is the first line of a class definition: Public class Tiger extends FelisIn what order will the class constructors execute?
In an inheritance relationship, this is the general class.a. Subclassb. Superclassc. Slave classd. Child class
What is an “is-a” relationship?
Write the first line of the definition for a Poodle class. The class should extend the Dog class.
Here is the first line of a class declaration. What is the name of the superclass? What is the name of the subclass?Public class Truck extends Vehicle
What is the purpose of the MIN_VALUE and MAX_VALUE variables that are members of the numeric wrapper classes?
What wrapper class methods convert a number from decimal to another numbering system? What wrapper classes are these methods a member of?
Write a statement that converts the following integer to a string and stores it in the String object referenced by str: Int i = 99;
Look at the following string: "Dog$cat@bird%squirrel"Write code using the String class’s split method that can be used to extract the following tokens from the string: dog, cat, bird, and
Look at the following code: String str = "one two three four";String[] tokens = str.split(" ");Int x = tokens.length;String first = tokens[0];What value will be stored in x? What value will the
The following string contains three tokens. What are they? What character is the delimiter? "Apples pears bananas"
How does the StringBuilder class’s replace method differ from the String class’s replace method?
True or False: You can use the = operator to assign a string to a StringBuilder object.
You wish to change a specific character in a StringBuilder object. What method do you use?
True or False: The StringBuilder class’s replace method can replace individual characters, but cannot replace substrings.
You wish to delete a specific character from the existing contents of a StringBuilder object. What method do you use?
True or False: The String class’s replace method can replace individual characters, but cannot replace substrings.
You wish to insert a string into the existing contents of a StringBuilder object. What method do you use?
True or False: The indexOf and lastIndexOf methods can find characters, but cannot find substrings.
You wish to add a string to the end of the existing contents of a StringBuilder object. What method do you use?
Morse code is a code where each letter of the English alphabet, each digit, and various punctuation characters are represented by a series of dots and dashes. Table 9-14 shows part of the code. Write
Look at the following statement: String city = "Asheville";Rewrite this statement so that city references a StringBuilder object instead of a String object.
In a program that makes lots of changes to strings, would it be more efficient to use String objects or StringBuilder objects? Why?
True or False: If toLowerCase method’s argument is already lowercase, it will be inadvertently converted to uppercase.
The String class is immutable. What does this mean?
True or False: If the toUpperCase method’s argument is already uppercase, it is returned as is, with no changes.
True or False: Character testing methods, such as isLetter, accept strings as arguments and test each character in the string.
Write a program that reads a sentence as input and converts each word to “Pig Latin”. In one version of Pig Latin, you convert a word by removing the first letter, placing that letter at the end
Many companies use telephone numbers like 555-GET-FOOD so the number is easier for their customers to remember. On a standard telephone, the alphabetic letters are mapped to numbers in the following
These static final variables are members of the numeric wrapper classes and hold the minimum and maximum values for a particular data type.a. MIN_VALUE and MAX_VALUEb. MIN and MAXc. MINIMUM and
Look at the following code: String str1 = "To be, or not to be";String str2 = str1.replace('o', 'u');System.out.println(str1);System.out.println(str2);You hear a fellow student claim that the
Showing 500 - 600
of 1252
1
2
3
4
5
6
7
8
9
10
11
12
13