Study

Revision 9

  •   0%
  •  0     0     0

  • If a is of type int and b is of type float what would be the resultant data type of a+b?
    float
  • The _______statement is used to avoid fall through
    break
  • State one similarity between while and for loop.
    entry controlled loops
  • p=5 and q=19: int n = (q-p)>(p-q)?(q-p):(p-q);
    14
  • Name the the types of conversion from one datatype to another
    implicit & explicit
  • The __________ function of the Scanner class is used to accept a character from the user
    next().charAt(0)
  • Name the primitive data type in Java that is: a single 16-bit Unicode character whose default value is ‘\u0000’
    char
  • Give one point of difference between unary and binary operators.
    Unary operator works on a single operand and Binary operator works on 2 operands
  • When are braces optional or necessary in conditional statements?
    braces are optional for if/else in case there is only one statement to be executed.
  • a=30, b=50; a = a + b; b = a – b; a = a – b; Print values of a & b
    50,30
  • State the difference between = and = =.
    In Java, “=” is the assignment operator and “==” is a comparison operator
  • Which Scanner methods allows us to input a number with a decimal point?
    nextFloat(), nextDouble()
  • y+=++y + y-- + --y; when int y=8
    33
  • State the number of bytes occupied by char and int data types.
    char =2 , int =4
  • int a = 63, b = 36; boolean x = (a < b ) ? true : false; int y= (a > b ) ? a : b; Print x & y
    false & 63
  • double a = - 6.35; double x = Math.abs(Math.ceil(a));
    6.0
  • The while loop is an exit controlled loop
    false
  • The return type of cbrt( ) function is _____________.
    double
  • Name two jump statements
    return,break,coninue
  • double num=Math.random(0); is a valid statement.
    false
  • Give Output: while(true) System.out.println('*');
    * endlessly in different lines