Question

in JAVA Which of the following attributes would be MOST appropriate for a class called Book,...

in JAVA

  1. Which of the following attributes would be MOST appropriate for a class called Book, that represents a book in a library?
  1. libraryName, location, libraryHours
  2. title, author, typeOfBook
  3. pages, cost, shipping
  4. anything, anytime, anywhere

  1. Which of the following statements is FALSE regarding constructors?
  1. A constructor allows you to set up an object once it is instantiated.
  2. A constructor does not have a return type.
  3. A constructor must have the same name as the name of the class.
  4. You can only have one constructor in a class definition.

  1. Fill in the Blanks
  1. The [___] modifier prevents variables from being accessed outside of the class. (Hint: it is a keyword)
  2. Class methods that have the public visibility modifier in its definition are known as [___] methods.

  1. Which of the following statements is TRUE?
  1. A toString method can be called automatically by passing an object through a println method
  2. Constructor methods must be explicitly called by the programmer
  3. Accessors methods are usually called setter methods
  4. Mutator methods are usually called getter methods

  1. If I create a class called Track with a static variable called star, and I proceed to make ten objects of type Track, how many copies of star is accessed by those objects?

Numeric Answer:

  1. Which of the following best describes a characteristic of an instance variable?
  1. Only one copy of this variable exists for all objects of that class.
  2. This variable is declared inside a method can be only be used by that method.
  3. Each object has its own version of this variable when the object is created.
  4. The value in this variable cannot change at all.

  1. Why is the main method static in our programs?
  1. Because we want the contents of the main method to remain constant
  2. Because we don't wish to create an object of type "class" just to run the main method
  3. Because we want to ensure that main is accessible to every program we've ever made
  4. Because main has been defined this way since the beginning of time and who are we to question that?

  1. Which of these is NOT a scenario in which a static modifier should be used?
  1. When you are defining the main method header in the driver program
  2. When you want to create a method but you don't want to call the method using an object
  3. When you want to define a constant that can be shared among several objects
  4. When you want to ensure that each object has is own version of the private members of the class

  1. Which scenario is NOT the best situation to use the this reference?
  1. When you want all methods in the object to be static.
  2. When you want to distinguish between the private members of the class and the parameters (which could have the same name).
  3. When you want one constructor to call another constructor.
  4. When you want to make it explicitly clear that an object is referring to itself .
0 0
Add a comment Improve this question Transcribed image text
Answer #1

The answers to the above questions are in the images attached below. They are

All the options other than correct options are very clear and I do think no explanation is needed for the right option. If you have any doubts feel free to post them via comments. If my work is appreciable please encourage me with a like.

Add a comment
Know the answer?
Add Answer to:
in JAVA Which of the following attributes would be MOST appropriate for a class called Book,...
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
  • Anyone helps me in a Java Languageif it it is possible thanks. Write a class called...

    Anyone helps me in a Java Languageif it it is possible thanks. Write a class called Player that holds the following information: Team Name (e.g., Ravens) . Player Name (e.g., Flacco) . Position's Name (e.g. Wide reciver) . Playing hours per week (e.g. 30 hours per week). Payment Rate (e.g., 46 per hour) . Number of Players in the Team (e.g. 80 players) . This information represents the class member variables. Declare all variables of Payer class as private except...

  • In Java Which of the following statements declares Salaried as a subclass of payType? Public class...

    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 :The following are descriptions of classes that you will create. Think of these as service...

    JAVA :The following are descriptions of classes that you will create. Think of these as service providers. They provide a service to who ever want to use them. You will also write a TestClass with a main() method that fully exercises the classes that you create. To exercise a class, make some instances of the class, and call the methods of the class using these objects. Paste in the output from the test program that demonstrates your classes’ functionality. Testing...

  • Create a class Circle with one instance variable of type double called radius. Then define an...

    Create a class Circle with one instance variable of type double called radius. Then define an appropriate constructor that takes an initial value for the radius, get and set methods for the radius, and methods getArea and getPerimeter. Create a class RightTriangle with three instance variables of type double called base, height, and hypotenuse. Then define an appropriate constructor that takes initial values for the base and height and calculates the hypotenuse, a single set method which takes new values...

  • 1. Do the following a. Write a class Student that has the following attributes: - name:...

    1. Do the following a. Write a class Student that has the following attributes: - name: String, the student's name ("Last, First" format) - enrollment date (a Date object) The Student class provides a constructor that saves the student's name and enrollment date. Student(String name, Date whenEnrolled) The Student class provides accessors for the name and enrollment date. Make sure the class is immutable. Be careful with that Date field -- remember what to do when sharing mutable instance variables...

  • Write a class called Book. Here are the relevant attributes: title author yearPublished            bookPriceInCAD Provide...

    Write a class called Book. Here are the relevant attributes: title author yearPublished            bookPriceInCAD Provide a constructor that takes parameters to initialize all the instance variables. The constructor calls the mutator (set) methods to initialize the instance variables. Provide an accessor (get) and mutator (set) for each instance variable. The mutators all validate their parameters appropriately and use them only if valid. If the passed parameter was invalid an IllegalArgumentException will be thrown with a proper error message A...

  • Java Program Name Final Part 2: Open Book 1. Define a Class called UFCFighter. a. Make...

    Java Program Name Final Part 2: Open Book 1. Define a Class called UFCFighter. a. Make instance variables for Name, Weight, Wins, and Loses(pick appropriate variable types). b. Create a static variable for TotalFights c. Create a default constructor that defaults name to "No Name yet", and al other variables to 0 d. Create a constructor that has parameters that set the value for name and weight, and sets wins and loses to 0. e. Create accessor methods for all...

  • Create a java class for an object called Student which contains the following private attributes: a...

    Create a java class for an object called Student which contains the following private attributes: a given name (String), a surname (family name) (String), a student ID number (an 8 digit number, String or int) which does not begin with 0. There should be a constructor that accepts two name parameters (given and family names) and an overloaded constructor accepting two name parameters and a student number. The constructor taking two parameters should assign a random number of 8 digits....

  • Create the following program in java please Write a class Store which includes the attributes: store...

    Create the following program in java please Write a class Store which includes the attributes: store name and sales tax rate. Write another class encapsulating a Book Store, which inherits from Store. A Book Store has the following additional attributes: how many books are sold every year and the average price per book. Code the constructor, accessors, mutators, toString and equals method of the super class Store and the subclass Book Store; In the Book Store class, also code a...

  • cs55(java) please. Write a class called Book that contains instance data for the title, author, publisher,...

    cs55(java) please. Write a class called Book that contains instance data for the title, author, publisher, price, and copyright date. Define the Book constructor to accept and initialize this data. Include setter and getter methods for all instance data. Include a toString method that returns a nicely formatted, multi-line description of the book. Write another class called Bookshelf, which has name and array of Book objects. Bookself capacity is maximum of five books. Includes method for Bookself that adds, removes,...

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