CTP 150 Final Exam
Which of Java packages is automatically imported into a Java program? - Answer- Consider the following code fragment: Circle c1 = new Circle(3); Circle c2 = new Circle(3); Circle c3 = c2; boolean condition = s(c1); What is the value of condition assuming that two circles are considered equal if they have the same radius value? - Answer- True Data hiding, which means that critical data stored inside the object is protected from code outside the object, is accomplished in Java by - Answer- Using the private access specifier on the class fields Given the following code, what will be the value of finalAmount when it is displayed? public class Order { private int orderNum; private double orderAmount; private double orderDiscount; public Order(int orderNumber, double orderAmt, double orderDisc) { orderNum = orderNumber; orderAmount = orderAmt; orderDiscount = orderDisc; } public double finalOrderTotal() { return orderAmount - orderAmount * orderDiscount; } }
Document information
- Uploaded on
- October 6, 2023
- Number of pages
- 14
- Written in
- 2023/2024
- Type
- Exam (elaborations)
- Contains
- Questions & answers