Advertisements
Advertisements
Question
Predict the output of the following code snippet: String P = "20", Q = "22";
int a = Integer.parseInt(P);
int b = Integer.value0f(Q);
System.out.println(a + " " + b);
Options
20
2220
20 22
22
Advertisements
Solution
20 22
Explanation:
A string like "" added to number makes it a string. Hence 20 + " " + 22 gives 20 22.
APPEARS IN
RELATED QUESTIONS
Write the memory capacity (storage size) of short and float data type in bytes.
State the number of bytes occupied by char and int data types.
Write a difference between the functions isUpperCase() and toUpperCase().
int res = ‘A’;
What is the value of res?
What is the data type returned by the library function?
compareTo()
What will be the output when the following code segment is executed?
System.out.println(“The king said\”Begin at the beginning!\“to me.”);
Give the output of the following code.
String A = "26.0", B= "74.0";
double C = Double.parseDouble(A);
double D = Double.parseDouble(B);
System.out.println((C+D));
Give the output of the following Character class method:
Character.isLetterOrDigit('W')Write the value of n after execution:
char ch = 'd';
int n = ch + 5;What is the method to check whether a character is a letter or digit?
