Question: Que11.Given the following method public static void updateNumber(int theNumber) { theNumber = theNumber + 6; System.out.println(theNumber); } What is the output of the following code
Que11.Given the following method
public static void updateNumber(int theNumber) { theNumber = theNumber + 6; System.out.println(theNumber); }
What is the output of the following code located in the same class?
int value = 7; System.out.println(value); updateNumber(value); System.out.println(value);
- A.
7 13 13
- B.
7 13 7
- C.
7 7 7
- D.
Runtime error because you can't change the value of theNumber in updateNumber.
Que12.Assume that you have an Account class with the following methods:
- Account(String id, String ownerName, double balance) // standard constructor
- void deposit(double amountToDeposit) // adds amountToDeposit to the balance
- String toString() // returns account data in the form "id ownerName balance"
Given the following method
public static void addToAccount(Account theAcct) { theAcct.deposit(200.0); System.out.println(theAcct); }
What is the output of the following code located in the same class?
Account acct = new Account("9876","John Doe",500.0); System.out.println(acct); addToAccount(acct); System.out.println(acct);
- A.
9876 John Doe $500.00 9876 John Doe $700.00 9876 John Doe $700.00
- B.
9876 John Doe $500.00 9876 John Doe $500.00 9876 John Doe $500.00
- C.
Runtime error because you can't change the value of theAcct in addToAccount.
- D.
9876 John Doe $500.00 9876 John Doe $700.00 9876 John Doe $500.00
Que13.A programmer wants to continue a loop provided the user has typed y or Y. Which of these is correct? Assume the input is stored in a variable more of type char.
- A.
while ( more == y || more == Y)
- B.
while ( more == y && more == Y)
- C.
while ( more == y && more == Y)
- D.
while ( more == y || more == Y)
Que14.Which is the correct order that the class, package, and import statements should appear? Select the one correct answer.
- A. class, import, package
- B. package, class, import
- C. import, class, package
- D. package, import, class
- E. import, package, class
Que15.Given the following code, what is the result when run? Select the one correct answer. public class Program { public static void main(String args [] ) { short x = 2; x++; short y = 3 + x++; System.out.print(y); } }
- A. 7
- B. 6
- C. 5
- D. An Exception occurs
- E. Compilation fails
Que16.Which of the following classes are immutable? Select the two correct answers.
| A. String | |
| B. JPanel | |
| C. java.util.Date | |
| D. Double | |
| E. java.sql.Date |
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
