Question: Question 2 What is output by the code below? public class Check { private int one, two, total; public void setNums(int n1, int n2) {
Question 2
What is output by the code below?
public class Check { private int one, two, total;
public void setNums(int n1, int n2) { one = n1; two = n2; }
public void add() { total = one + two; two = 9; }
public String toString() { total = 2; return "" + total; } }
//code in the main of another class
Check test = new Check(); test.setNums(9,7); test.add(); out.println(test);
Question 2 options:
| 18 | |
| 12 | |
| 14 | |
| 16 | |
| 2 |
Question 3
What is output by the code below? System.out.println( Math.pow( Math.sqrt(81),2) );
Question 3 options:
| 9.0 | |
| 18.0 | |
| 81.0 | |
| 91.0 | |
| 27 |
Question 4
Never put a semicolon before an open what?
Question 4 options:
| comma | |
| semi-colon | |
| window | |
| curly brace | |
| chicken |
Question 5
Which of the following lines correctly defines a String variable?
Question 5 options:
| String s = cdef; | |
| s = "cdef"; | |
| String s = "cdef"; | |
| String = "cdef"; | |
| String; |
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
