50)?"base":"ball"; System.out.println(s); } } null ball base None D is correct. This is a ternary nest"> 50)?"base":"ball"; System.out.println(s); } } null ball base None D is correct. This is a ternary nest">
logo

CuriousTab

CuriousTab

Discussion


Home Interview Technology Comments

  • Question
  • class Hell { public static void main(String[] args) { Integer i = 42; String s = (i<40)?"life":(i>50)?"base":"ball"; System.out.println(s); } }


  • Options
  • A. null
  • B. ball
  • C. base
  • D. None

  • Correct Answer
  • ball 

    Explanation

    D is correct. This is a ternary nested in a ternary with a little unboxing thrown in.Both of the ternary expressions are false.


  • Technology problems


    Search Results


    • 1. Which is true?

    • Options
    • A. "X extends Y" is correct if and only if X is a class and Y is an interface
    • B. "X extends Y" is correct if and only if X is a class and Y is an interface
    • C. "X extends Y" is correct if X and Y are either both classes or both interfaces
    • D. "X extends Y" is correct for all combinations of X and Y being classes and/or interfaces
    • Discuss
    • 2. Which of the following is not used for commenting in java?

    • Options
    • A. //
    • B. /* */
    • C. /** */
    • D. /** **/
    • Discuss
    • 3. What is the impact of declaring a method as final?
    • Discuss
    • 4. What is the access scope of a protected method?
    • Discuss
    • 5. How to define a constant variable in Java?
    • Discuss
    • 6. try { int x = Integer.parseInt("two"); } Which could be used to create an appropriate catch block?

    • Options
    • A. ClassCastException
    • B. IllegalStateException
    • C. NumberFormatException
    • D. None
    • Discuss
    • 7. Difference between Java Beans & Servlets?
    • Discuss
    • 8. Just by seeing the signature of the bean how can you specity whether it is a Statefull of Stateless Session Bean?
    • Discuss
    • 9. How are this() and super() used with constructors?
    • Discuss
    • 10. How do you decide when to use HashMap and when to use TreeMap ?
    • Discuss


    Comments

    There are no comments.

Enter a new Comment