Advertisements
Advertisements
प्रश्न
Differentiate between if else if and switch-case statements.
Advertisements
उत्तर
| if-else if | switch-case |
| (i) It evaluates integer, character, pointer or floating-point type or boolean type. | (i) It evaluates only character or integer value. |
| (ii) Which statement will be executed depend upon the output of the expression inside if statement. | (ii) Which statement will be executed is decided by user. |
APPEARS IN
संबंधित प्रश्न
State the number of bytes occupied by char and int data types.
State the data type and value of res after the following is executed:
char ch = ‘t’;
res=Character. toUpperCase(ch);
Write a difference between the functions isUpperCase() and toUpperCase().
Write the return data type of the following function:
log( )
What will be the output when the following code segment is executed?
String s = “1001”;
int x = Integer. valueOf(s);
double y = Double.valueOf(s);
System.out.println(“x=”+x);
System.out.println(“y=”+y);
Give the output of the following Character class method:
Character.toUpperCase('a')Write the value of n after execution:
char ch = 'd';
int n = ch + 5;The method to convert a lowercase character to uppercase is ______.
Predict the output of the following code snippet:
char ch='B';
char chr=Character.toLowerCase(ch);
int n=(int)chr-10;
System.out.println((char)n+"\t"+chr);
A student is trying to convert the string present in x to a numerical value, so that he can find the square root of the converted value, However the code has an error. Name the error (syntax/logical/runtime). Correct the code so that it compiles and runs correctly.
String x="25";
int y=Double.parseDouble(x);
double r=Math.sqrt(y);
System.out.println(r);