Given:
public class Test1 {
static void doubling (Integer ref, int pv) { ref =20;
pv = 20;
}
public static void main(String[] args) { Integer iObj= new Integer(10);
int iVar = 10; doubling(iObj++, iVar++);
System.out.println(iObj+ ", "+iVar); What is the result?
Correct Answer:
A
The code doubling(iObj++, iVar++); increases both variables from to 10 to 11.
boolean log3 = ( 5.0 != 6.0) && ( 4 != 5);
boolean log4 = (4 != 4)|| (4 == 4); System.out.println("log3:"+ log3 + \nlog4" + log4);
What is the result?
Correct Answer:
B
public class ForTest {
public static void main(String[] args) { int[] arrar= {1,2,3};
for ( foo ) {
}
}
}
Which three are valid replacements for foo so that the program will compiled and run?
Correct Answer:
ABC
Given the for loop construct:
for ( expr1 ; expr2 ; expr3 ) { statement;
}
Which two statements aretrue?
Correct Answer:
BC
The for statement have this forms: for (init-stmt;condition;next-stmt) { body
}
There are three clauses in the for statement.
The init-stmt statement is done before the loop is started, usually to initialize an iteration variable.
The condition expression is tested before each time the loop is done. The loop isn\'t executed if the boolean expression is false (the same as the while loop).
The next-stmt statement is done after the body is executed. It typically increments an iteration variable.
View the exhibit:
< ><>< ><>What is the result when this program is executed?
Correct Answer:
B
After the statement jian = bob; the jian will reference the same object as bob.
