If s1 and s2 were both referring to literals, then I would be correct, but the new operator forces a new object to be created.This is the code for my quiz. I is not correct since s1 and s2 are two different objects (even though they have the same characters).The only one that will not be true is I, since s1 and s2 are two different objects (even though they have the same characters). And s2 and s3 both refer to string that have the same characters so equals will be true in IV. Number II is correct since s3 and s1 are referencing the same string, so they will be =. So II is correct since s1 and s2 have the same characters. The = operator checks if two object references refer to the same object. String overrides equals to check if the two string objects have the same characters.It would also be better to group a couple of pieces of data into a single class.ฤก String s1 = new String ( "Hi There" ) 2 String s2 = new String ( "Hi There" ) 3 String s3 = s1 4 5 I. A car doesn't really make sense to be a subclass of AC, and so on.Use three classes: Doors, AirConditioning, and MilesPerGallon, each with a subclass Car.It doesn't really make sense for AC to be a subclass of MPG, and that being a subclass of Doors.Use a class Car, which has a subclass Doors, with a subclass AC, with a subclass MPG.In this case, the information only refers to a couple of basic attributes so it is better to store that data as fields within a single class.Use a class, Car, which has three subclasses: Doors, MilesPerGallon, and AirConditioning.The point of storing the car information is so we can easily access the attributes related to a car.Use four unrelated classes: Car, Doors, MilesPerGallon, and AirConditioning.Having one class with all the attributes needed is the most efficient design in this case.Use one class, Car, which has three attributes: int numDoors, double mpg, and boolean hasAir.Which of the following is the best design? 2-13-12: A car dealership needs a program to store information about the cars for sale.For each car, they want to keep track of the following information: the number of doors (2 or 4),its average number of miles per gallon, and whether the car has air conditioning.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |