Answered step by step
Verified Expert Solution
Question
1 Approved Answer
45. The purpose of defining the equals() method in a class is a. to check if an object is null b. to check equality
45. The purpose of defining the equals() method in a class is a. to check if an object is null b. to check equality of objects field-by-field c. to check if two objects of the class are identical d. to check if the data fields have default values e. none of the above 46. Which statement holds true for the chess method headers taken from a class named Games public void chess (Person player1, Person player2) public Person chess (int winner) public double chess (double award) public int chess (Person master) a. Correct overloading of the chess method b. The class does not compile, because the return types are all different c. Incorrect attempt of overloading, because the methods must be static CS 16000-04 Introduction to Computer Science I d. Incorrect attempt of overloading, because type Person is used in two methods e. None of the above Spring Semester 2022 47. The expression below refers to the combining of data and code into a single object a. Data hiding b. A public class c. Encapsulation d. The new operator e. Variable declaration 11 48. For the following code, which statement is true? public class Circle{ private double radius = 15; public double area (double radius) { return Math.PI*radius*radius; } } a. The code has a compiler error b. The method parameter and field are the same variables. c. The method returns the area of this circle of radius 15. d. In the area formula, radius takes the parameter value. e. None of the above 49. Data hiding in Java means that a. the fields are static b. the fields cannot be accessed by its method c. the fields cannot be accessed directly from an external code d. a local variable in a method hides an instance field of the same name e. all the above 50. It is common practice in object-oriented programming to a. declare the fields private b. aggregate classes to other classes CS 16000-04 Introduction to Computer Science I 12 Spring Semester 2022 c. design multiclass solutions to programming problems d. create programs that are made of objects which can store data and perform operations e. perform all the above 51. (5 points) Consider public class Rectangle { private static int nosOfInstances Created } public Rectangle() { nosOfInstancesCreated++} public static int getNos Instances Created() { in main method, we have //Number of instance(s) of Rectangle is/are created Rectangle box1; = 0; System.out.print(Rectangle.getNos Instances Created() + "); box1 = new Rectangle(); The output to the console is: return nos Instances Created; } IT System.out.print(Rectangle. getNos InstancesCreated() + Rectangle box2 = new Rectangle(); System.out.print(box2. getNos Instances Created () + "); Rectangle box3; a. 1 2 1 1 2 b. 1 2 3 4 5 C. 0 1 1 0 1 d. 0 1 2 2 3 e. None of the above System.out.print( Rectangle.getNos Instances Created() + "H box3= new Rectangle(); System.out.print( Rectangle.getNos InstancesCreated()); 11 "Li "
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started