-
In Java
Which of the following statements declares Salaried as a
subclass of payType?
Public class Salaried implements PayType
Public class Salaried derivedFrom(payType)
Public class PayType derives Salaried
Public class Salaried extends PayType
If a method in a subclass has the same signature as a method in
the superclass, the subclass method overrides the superclass
method.
False
True
When a subclass overloads a superclass method……….
Only the subclass method may be called with a subclass
object
Only the superclass method...
-
********************Java
Assigment*******************************
1. The following interface and classes have to do with the
storage of information that may appear on a mailing label. Design
and implement each of the described classes below.
public interface AddrLabelInterface {
String getAttnName();
String getTitle(); // Mr., Mrs., etc.
String getName(); String getNameSuffix(); // e.g., Jr., III
String getProfessionalSuffix(); // O.D. (doctor of
optometry)
String getStreet();
String getSuiteNum();
String getCity();
String getState();
String getZipCode(); }
Step 1
Create an abstract AddrLabel class that implements the...
-
PRG/421 Week One Analyze Assignment –
Analyzing a Java™Program Containing
Abstract and Derived Classes
1. What is the output of the program as
it is written? (Program begins on p. 2)
2. Why would a programmer choose to define a method in an
abstract class (such as the Animal constructor method or the
getName()method in the code example) vs. defining a method
as abstract (such as the makeSound()method in the
example)?
/**********************************************************************
* Program: PRG/421
Week 1 Analyze Assignment
* Purpose: Analyze
the coding for...
-
QUESTION 21 In the Java programming language method overriding occurs when (a) and precedes the call with an @Override annotation a method in a child class calls the method of the same name in one of its ancestor classes (b) when a class defines an abstract method and precedes the declaration with an @Override annotation two or more methods of a class have the same name but different signatures and both of (c) them are marked with an @Override annotation...
-
44
A method signature defines which of the following? (choose all
that apply)
return type
name
call
parameters
body
45
An abstract class can be implemented using the
implements keyword.
True
False
46
An abstract class can be extended using the
extends keyword.
True
False
47
Abstract classes are represented in UML by:
italics
underline
plus/minus
bold
48
An abstract class is a superclass for a subclass.
True
False
49
These symbols are used to denote an interface in a...
-
This is the question about object-oriend programming(java)
please show the detail comment and prefect code of each
class, Thank you!
This question contain 7 parts(questions)
Question 1
Create a class a class Cat with the following UML
diagram:
(the "-" means private , "+" means public)
+-----------------------------------+
| Cat |
+-----------------------------------+
| - name: String |
| - weight: double |
+-----------------------------------+
| + Cat(String name, double weight) |
| + getName(): String |
| + getWeight(): double |
|...
-
A Java Program
Purpose:
Work with Abstract classes.
Purpose:
Abstract classes are import because they ensure than any children
which inherit from it must implement certain methods. This is done
to enforce consistency across many different classes.
Problem:
Implement a class called Student. This class needs
to be abstract and should contain a String for the
name, and a String for the major
(and they should be private). The class must have a constructor to
set the name and major....
-
JAVA
QUESTION 1
The value returned by a value-returning method can be saved for
further calculation in the program.
True
False
QUESTION 2
To use a predefined method you must know the code in the body of
the method.
True
False
QUESTION 3
A formal parameter is a variable declared in the method heading
(ie. it's signature).
True
False
QUESTION 4
A local identifier is an identifier that is declared within a
method or block and that is visible only...
-
JAVA
Question 1
When implementing a method, use the class’s set and
get methods to access the class’s ________ data.
a. public.
b. private.
c. protected.
d. All of the above.
Question 2
Set methods are also commonly called ________ methods
and get methods are also commonly called ________
methods.
a. query, mutator.
b. accessor, mutator.
c. mutator, accessor.
d. query, accessor.
Question 3
Composition is sometimes referred to as a(n) ________.
a. is-a relationship
b. has-a relationship
c. many-to-one...
-
if we have following List classes:
public class LinkedList<T> {
class ListNode {
protected T value;
protected ListNode next;
public ListNode(T val, ListNode nxt) {
value = val;
next = nxt;
}
public ListNode(T val) {
this(val, null);
}
public ListNode() {
this(null, null);
}
}
can you write the folowing methods in java:
1.Write a method for the LinkedList class called int indexOf(T
val) which returns the integer index indicating the location of val
in the list, or -1...