Logo

Java Questions Set 54:

Quiz Mode

The '&' operator can return - 

1
2
3
4

Solution:

Which of these integer constants are defined in the ActionEvent class?

1
2
3
4

Solution:

Which event is generated when a component is added to or removed from a container?

1
2
3
4

Solution:

What will str contain after successfully running following lines of code?

 

StringBuffer str = new StringBuffer("Hello");
str.deleteCharAt(0 , 2);

1
2
3
4

Solution:

What does the following code output?

1
2
3
4
5

Solution:

Which will legally declare, construct, and initialize an array?

1
2
3
4

Solution:

What does the Liskov Substitution Principle specify?

1
2
3
4

Solution:

What will be the output of the program?

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

1
2
3
4

Solution:

What will be the output of the following Java program?


import java.lang.System;

class Output

{

public static void main(String args[])

{

long start, end;

start = System.currentTimeMillis();

for (int i = 0; i < 10000000; i++);

end = System.currentTimeMillis();

System.out.print(end - start);

}

}

1
2
3
4

Solution:

What will be the output of the following Java program?


import java.io.*; public class filesinputoutput { public static void main(String[] args) { String obj = "abc"; byte b[] = obj.getBytes(); ByteArrayInputStream obj1 = new ByteArrayInputStream(b); for (int i = 0; i < 2; ++i) { int c; while ((c = obj1.read()) != -1) { if(i == 0) { System.out.print((char)c); } } } } }

1
2
3
4

Solution: