You are on page 1of 1

ASPIRE | Java |Quiz Answers 1.

Given the following class definition, which of the following methods could be legally placed after the comment //Here public class Rid{ public void amethod(int i, String s){} //Here } Ans: public void Amethod(int i, String s) {} 2. Which of the following are primitive types? Ans: Byte 3. What will happen when you attempt to compile and run the following code public class Hope{ public static void main(String argv[]){ Hope h = new Hope(); } protected Hope(){ for(int i =0; i <10; i ++){ System.out.println(i); } } } Ans: Compilation and running with output 0 to 9 4. Class conditional { public static void main(String args[]) { int i = 20; int j = 55; int z = 0; z = i < j ? i : j; // ternary operator System.out.println(The value assigned is + z); } } What is output of the above program? Ans: 20 5. Which of the following statements are true? Ans: Strings are a primitive type in Java that overloads the + operator for concatenation --For More, Join Us @ www.facebook.com/groups/tcsilpaspire

You might also like