Fundamental Operators And Wrapper Classes

15 Questions | Total Attempts: 45

SettingsSettingsSettings
Fundamental Operators And Wrapper Classes - Quiz

Questions and Answers
  • 1. 
    IsNaN is made available in
    • A. 

      long

    • B. 

      short

    • C. 

      double

    • D. 

      byte

  • 2. 
    The three most important methods available in the wrapper classes are:
    • A. 

      XxxValue()

    • B. 

      Valueof()

    • C. 

      ParseXxx()

    • D. 

      Xxxvalue()

    • E. 

      ValueOf()

    • F. 

      ParseXxx()

  • 3. 
    Read the following program   class test {                 public static void main(String [] args)                 {                                 int x = 3;                                 int y = 1;                                 if (x = y)                                                 System.out.println("Equal");                                 else                                                 System.out.println("Not Equal");                 } }   What is the result?
    • A. 

      The output is Equal

    • B. 

      The output is Not Equal

    • C. 

      An error at " if (x = y)" causes compilation to fall.

    • D. 

      The program executes but no output is show on console.

  • 4. 
    What is the output? class Test {     public static void main(String [] args)     {         int x=20;         String sup = (x < 15) ? "small" : (x < 22)? "tiny" : "huge";         System.out.println(sup);     } }
    • A. 

      Small

    • B. 

      Tiny

    • C. 

      Huge

    • D. 

      Compilation fails

  • 5. 
    Primitive data types
    • A. 

      Are also called as objects

    • B. 

      Are not objects

    • C. 

      Cannot access methods of object class

    • D. 

      Can access methods of object class

  • 6. 
    Which of the following are legal identifiers
    • A. 

      2variable

    • B. 

      Variable2

    • C. 

      _whatavariable

    • D. 

      _3_

    • E. 

      $anothervar

    • F. 

      #myvar

  • 7. 
    Class train {                  public static void main(String[] args)                  {                   Integer x = 0;                   int  y= 0;                   for(int z = 0; z < 5; z++)                                   if ((++x > 2) || (++y>1))                                                   x++;                   System.out.println(x + " " + y);                 }   } What is the output of the following program?
    • A. 

      8 0

    • B. 

      8 1

    • C. 

      9 2

    • D. 

      9 1

  • 8. 
    The default keyword can be located anywhere in the
    • A. 

      Switch block

    • B. 

      Switch expression

    • C. 

      Switch statement

    • D. 

      Switch construct

  • 9. 
    Wrapper classes are -----------
    • A. 

      Extensible

    • B. 

      Immutable

    • C. 

      Serializable

    • D. 

      All the above

  • 10. 
    The easiest way to turn a number into a string is to simply concatenate using
    • A. 

      +

    • B. 

      -

    • C. 

      &

    • D. 

      *

  • 11. 
    What is the output of System.out.println(-3>>>1)?
    • A. 

      2147483646

    • B. 

      1

    • C. 

      2

    • D. 

      Cannot be shifted

  • 12. 
       double c=Double.parseDouble("50h");    System.out.println(c);   What is the output of the above program?
    • A. 

      50h

    • B. 

      This results in compile time error'Number Frame Exception'

    • C. 

      This results in runtime error 'Number Format Exception'

    • D. 

      50

  • 13. 
       boolean b;    System.out.println(b);   What is the output of the above program?
    • A. 

      True

    • B. 

      False

    • C. 

      Null

    • D. 

      0

  • 14. 
    Which will legally declare, construct, and initialize an array?
    • A. 

      Int [] myList = {"1", "2", "3"};

    • B. 

      Int [] myList = (5, 8, 2);

    • C. 

      Int myList [] [] = {4,9,7,0};

    • D. 

      Int myList [] = {4, 3, 7};

  • 15. 
    What gets printed when the following program is compiled and run. Select the one correct answer.   class test {                 public static void main(String args[]) {                                 int i,j,k,l=0;                                 k = l++;                                 j = ++k;                                 i = j++;                                 System.out.println(i);                                    } }
    • A. 

      0

    • B. 

      1

    • C. 

      2

    • D. 

      3

Related Topics
Back to Top Back to top