Question

JAVA Question 1 When implementing a method, use the class’s set and get methods to access...

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.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

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.

Add a comment
Know the answer?
Add Answer to:
JAVA Question 1 When implementing a method, use the class’s set and get methods to access...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Can someone please help with this in JAVA? Write one application program by using the following...

    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...

  • A JavaBean, or bean, is a Java class that A. doesn’t provide get and set methods...

    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

  • QUESTION 1 In Java, all variables declared using a class are ____. a. reference variables b....

    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....

    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...

    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...

    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...

  • DI Question 2 1.5 pts Which situations allow the client main() in the file my_program.py to access a method name, say f...

    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...

  • Question 1 (24 Marks] 1. (4 marks) Write an immutable Person class in Java which provides...

    Question 1 (24 Marks] 1. (4 marks) Write an immutable Person class in Java which provides the following. • Two attributes: lastName and first Name of type String. • Appropriate initialization, accessors/mutator methods. 2. (6 marks) Write a Student class that is a subclass of Person class (in the previous question) which provides the following. • Two attributes: A unique student ID of type String and GPA of type float; the student ID is initialized when a Student object gets...

  • QUESTION 21 In the Java programming language method overriding occurs when (a) and precedes the call with an @Override...

    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...

  • In Java Main method Your main program will prompt the user for a test name and...

    In Java Main method Your main program will prompt the user for a test name and the number of scores the user will enter. After creating an arraylist to hold the scores, prompt the user for all the scores to hold in the arraylist. After all the scores are entered, then repeat back the score & letter grade. GradeBook Object Create an instance of a GradeBook object and pass the test name and arraylist to set the instance variables. At...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT