Tag: java
Questions Related to java
int x = 12;
while (x < 10) {
x--;
}
System.out.print(x);
What is the result?
System.out.format("Pi is approximately %d.", Math.PI);
What is the result?
NumberFormat nf = NumberFormat.getInstance(); nf.setMaximumFractionDigits(4);
nf.setMinimumFractionDigits(2);
String a = nf.format(3.1415926);
String b = nf.format(2);
Which statement is true about the result?
public class Yippee2 {
static public void main(String [] yahoo) {
for(int x = 1; x < yahoo.length; x++) {
System.out.print(yahoo[x] + " ");
}
}
}
and the command line invocation: java Yippee2 a b c
What is the result?
public static void main(String[] args) {
String str = "null";
if (str == null) {
System.out.println("null");
} else (str.length() == 0) {
System.out.println("zero");
} else {
System.out.println("some");
}
}
What is the result?
String[] elements = { "for", "tea", "too" };
String first = (elements.length > 0) ? elements[0] : null;
What is the result?