Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

You are trying to compare two primitive variable, what comparison symbol you sho

ID: 3683181 • Letter: Y

Question

You are trying to compare two primitive variable, what comparison symbol you should use? You are trying to compare two java objects for its content, what is the method name you should use? You are designing a class with several private instance variable, can these variables be accessed by methods outside of the class definition? If you try to read the value of a private instance variable outside of the class, what kind of method you should use? You are designing a class with several private instance variable, to allow the class user to update the variable values, what kind of method they should use? You are designing a class with several private instance variables to comply with the cacapsulation OOP principle, to allow other class to access these variables? You would design special methods for read operations, what kind of methods are these? What should be the prefix for the method name? You would design special methods for write operations, what kind of methods are these? What should be the prefix for the method name? Study the separately distributed class source file then answer the following question: In line 7, there is no public modifier (keyword). What would happen if put it back and compile the class? Explain briefly. We save the source as why we do this way, instead of save it as and run as Calc_BMI? If we delete line 6, what would happen when trying to complete? Can you execute class Calc-BMI without using a main method to derive it? YES NO Notice that the class name is in line 7: Calc_BMI, but there are four same name methods from LINE 13 to 16, what do we call these methods.

Explanation / Answer

6

ans1 == and != Operators,

ans2 .equals(), .compareTo(), .compare()

7

ans1 No

ans2 Variables that are declared private can be accessed outside the class if public getter methods are present in the class.

8

Ans- Variables that are declared private can be accessed outside the class if public setter methods are present in the class.

9

Ans1- getter methods, Ans2-‘get’ as prefix

Ans3-setter methods, Ans4- ‘set’ as prefix

10

To answer this the source file DEMO_Calc_BMI.java is needed.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote