| 31. |
What will be the output of the following Java program?
interface calculate
{
void cal(int item);
}
class display implements calculate
{
int x;
public void cal(int item)
{
x = item * item;
}
}
class interfaces
{
public static void main(String args[])
{
display arr = new display;
arr.x = 0;
arr.cal(2);
System.out.print(arr.x);
}
}
|
||||||||
|
Answer:
Option (c) |
| 32. |
Which of the following is the correct way of implementing an interface A by class B?
|
||||||||
|
Answer:
Option (b) |
| 33. |
All methods must be implemented of an interface.
|
||||
|
Answer:
Option (a) |
| 34. |
What type of variable can be defined in an interface?
|
||||||||
|
Answer:
Option (d) |
| 35. |
What does an interface contain?
|
||||||||
|
Answer:
Option (b) |
| 36. |
What type of methods an interface contain by default?
|
||||||||
|
Answer:
Option (a) |
| 37. |
What will happen if we provide concrete implementation of method in interface?
|
||||||||
|
Answer:
Option (c) |
| 38. |
What happens when a constructor is defined for an interface?
|
||||||||
|
Answer:
Option (a) |