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 relationship
d. one-to-many relationship
Question 4
Instance variables declared final do not or cannot:
a. Cause syntax errors if used as a left-hand value.
b. Be initialized.
c. Be modified after they are initialized.
d. None of the above.
Question 5
Inheritance is also known as the
a. knows-a relationship.
b. has-a relationship.
c. uses-a relationship.
d. is-a relationship.
Question 6
Which of the following is not a superclass/subclass relationship?
a. Employee/Hourly Employee.
b. Vehicle/Car.
c. Sailboat/Tugboat.
d. None of the above.
1) All of the above
set and get method are basically introduced to have private members in place and could be accessed only via object to that class. Hence we can say when we talk about get and set methods they provide access to private data but there is no restriction that only private data can have get, set method even other members public and protected as well.
2) mutator, accessors
Set methods are also called mutators (derived from word mutate which means to become different).Set methods set the value of variable hence making change to variables.
Get methods are also called accessors. These are used to return the value of variable and hence we are able to access the value that's why called accessors.
3) has-a
Composition is done by having an instance of another class. When you don't want to have all the properties inherited of some other class instead wants to have the class instance then you can make instance of that class as a field.
4) Be modified after they are initialized
Final variables are like constant whose value cannot be changed once assigned.
5) is-a relationship.
Inheritance is also known as is-a relationship. When we inherit some class to another class then subclass becomes of base class type. Car inherits Vehicle or we can say Car is-a Vehicle.
6) Sailboat/Tugboat
Sailboat and Tugboat both are type of boat so they don't make a superclass/subclass relationship with each other.
JAVA Question 1 When implementing a method, use the class’s set and get methods to access...
Can someone please help with this in JAVA? Write one application program by using the following requirements: 1) Exception handling 2) Inheritance a) At least one superclass or abstract superclass: this class needs to have data members, accessor, mutator, and toString methods b) At least one subclass: this class also needs to have data members, accessor, mutator, and toString methods c) At least one interface: this interface needs to have at least two abstract methods d) At least one method...
Need help extending and constructing this problem in JAVA using the given guidelines. public class gatorade { public void nutrition() { System.out.println("nutrition facts method"); System.out.println("90 Calories"); System.out.println("0 Grams Fat"); System.out.println("20 MG Sodium"); System.out.println("18 Grams Sugar"); System.out.println("0 Grams Protein"); } } //inheritance public class blueberry extends gatorade{ System.out.println("Color is blue"); public class orange extends gatorade{ System.out.println("Color is orange"); public class lemonlime extends gatorade{ System.out.println("Color is yellow"); public class fruitpunch extends gatorade{ System.out.println("Color is red"); ________________________________________________________ Write one application program by using...
A JavaBean, or bean, is a Java class that A. doesn’t provide get and set methods for all of it’s private instance variables that follow standard Java naming conventions B. doesn’t provide a zero-argument constructor C. declares public instance variables D. None of the above
****Please read the following requirements and use java language w/ comments**** ****Can make this a multi part question if needed**** Project requires a base class, a derived subclass, and an interactive driver (class with a main) that allows the user to utilize and manipulate the classes created. You may select one super class from the following: Superclass Example subclasses Ship class a) battleship, tugboat, icebreaker Person class b) manager, salaryworker, hourlyworker Aircraft class c) Learjet, cargoplane,...
QUESTION 1 In Java, all variables declared using a class are ____. a. reference variables b. constants c. primitive variables d. operators 1 points QUESTION 2 An expression such as str.length(); is an example of a(n) ____. a. system call b. method call c. object call d. class 1 points QUESTION 3 Consider the following statements. double x; String y; y = String.format( "%.2f", x); If x = 285.679, what is the value of y? a. "285.00" b....
1. Properties can contain both ______________ accessors. a. get and value b. get and set c. return and set d. return and value 2. Identify the correct statement from the following: a. Properties cannot specify arbitrary parameters, although methods can. b. Read-only properties have both get and set accessors. c. Both properties and methods can be of type void. 3. Identify the correct explanation of an indexer. a. Indexers are differentiated by name, and a class can declare two indexers...
Question 1 If a method is marked as protected internal, who can access it? Classes that are both in the same assembly and derived from the declaring class. Only methods that are in the same class as the method in question. Internal methods can only be called using reflection. Classes within the same assembly, and classes derived from the declaring class Question 2 To avoid having to use fully qualified referenced classes, you could: Add a reference to the class....
ATM Revisited In Java, design a subclass of the Account class called GoldAccount. It is still an Account class, however it has an additional field and some additional functionality. But it will still retain all the behavior of the Account class. Write a class called GoldAccount. This class will have an additional private field called bonusPoints. This field will require no get or set methods. But it will need to be initialized to 100 in the constructor. Thereafter, after a...
Java: Create a class called Vehicle with the following features: a. It has three private data members (instance variables): one is the manufacturer’s name (String manufacturer), the second is the number of cylinders in the engine (int cylinder), and the third is the owner (Person owner). The class Person is described above. b. It has three constructors, a no-argument constructor, a constructor with three parameters, and a copy constructor. The no-argument constructor will set the manufacturer to “None”, cylinder to...
DI Question 2 1.5 pts Which situations allow the client main() in the file my_program.py to access a method name, say func(), alone, as in x-func) without dereferencing it using prepended name like modname.func or x = some object. func () or x-SomeClass.func() O func) is defined in some module, say, "modname.py" and modname is imported into my_program.py using: from modname import func() is an instance method or a class method in a class, say SomeClass, defined in the same...