Tag: java
Questions Related to java
public class CreditCard {
private String cardID;
private Integer limit;
public String ownerName;
public void setCardInformation(String cardID, String ownerName, Integer limit) {
this.cardID = cardID;
this.ownerName = ownerName;
this.limit = limit;
}
}
Which statement is true?
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?
After the declaration: char[] c = new char[100]; what is the value of c[50]?