Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. public class MysteryBox { private int my Int; private boolean biga; private String label; public MysteryBox (int a, int b, String label) { myInt

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

1. public class MysteryBox { private int my Int; private boolean biga; private String label; public MysteryBox (int a, int b, String label) { myInt = a / 2; bigA = (a > b); thir dabet = label; // Something's missing here... } public void shake () { myInt = 5; } public int getMysteryNumber() { return myInt; } public boolean getBigA() { return bigA; } } 1a. How would you properly set MysteryBox's private label variable inside its constructor? a. label = label; b. this.label = label; C. label = this.label; d. this.label = this.label; e. myLabel = label; 11. Which of these constructs a MysteryBox with myint equal to 2, and bigA equal to true? a. Mystery Box box = new MysteryBox(2, 1, "false"); b. Mystery Box box = new MysteryBox(4, 2, "false"); C. Mystery Box box = new MysteryBox(2, 4, "true"); d. Mystery Box box = new MysteryBox(4, 8, "true"); MysteryBox box = new MysteryBox(8, 6, "What's in the box?"); box. shake(); int x = box.getMysteryNumber(); boolean check = box.getBigA(); 1c. What is the value of x? a. 8 b. 6 C. 5 d. 4 e3 1d. What is the value of check? a True b. False +2. public class ConfusingBox extends MysteryBox { private int myB; public confusingBox(int a, int b, String label) { super(a, 5, label); this.myB = b; } public boolean getBigA() { return false; } public int getB() { return b; } 2a. Which of the following creates a ConfusingBox with myint equal to 2, bigA (the private variable) equal to true, and myB equal to 25? a. Confusing Box box = new ConfusingBox(2, 1, "Help me."); b. Confusing Box box = new ConfusingBox(4, 2, "I'm trapped in this box."); C. Confusing Box box = new ConfusingBox(4, 25, "I can't get out."); d. ConfusingBox box = new ConfusingBox (2, 25, "Hello???"); e. There is no way to create a ConfusingBox with those values 2b. What is the value of x? ConfusingBox box = new ConfusingBox(3, 2, "One"); boolean x = box.getBigA(); a True b. False C. The code does not compile 2c. What is the value of x? 2c. What is the value of x? Box box = new ConfusingBox (3, 2, "One"); boolean x = box.getBigA(); True False The code does not compile

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

SQL Database Programming

Authors: Chris Fehily

1st Edition

1937842312, 978-1937842314

More Books

Students also viewed these Databases questions