Java Programming Questions & Answers: part1



Software Programming : Java Programming QUESTIONS AND ANSWERS :: part1 : 1 to 5

Following Software Programming language Entrance Multiple choice objective type questions and answers will help you in Software Programming 2024 examinations :

1.Which of the following is not true?

An interface can extend another interface.
A class which is implementing an interface must implement all the methods of the interface.
An interface can implement another interface.
An interface is a solution for multiple inheritance in java.
None of the above.

2.Which statement is not true in java language?

A public member of a class can be accessed in all the packages.
A private member of a class cannot be accessed by the methods of the same class.
A private member of a class cannot be accessed from its derived class.
A protected member of a class can be accessed from its derived class.
None of the above.

3.Consider the following code fragment Rectangle r1 = new Rectangle(); r1.setColor(Color.blue); Rectangle r2 = r1; r2.setColor(Color.red); After the above piece of code is executed, what are the colors of r1 and r2 (in this order)?

Color.blue
.red
Color.blue
.blue
Color.red

4.Consider the two methods (within the same class) public static int foo(int a, String s) { s = "Yellow"; a=a+2; return a; } public static void bar() { int a=3; String s = "Blue"; a = foo(a,s); System.out.println("a="+a+" s="+s); } public static void main(String args[]) { bar(); } What is printed on execution of these methods?

a = 3 s = Blue
a = 5 s = Yellow
a = 3 s = Yellow
a = 5 s = Blue
none of the above.

5.What is the type and value of the following expression? (Notice the integer division) -4 + 1/2 + 2*-3 + 5.0

int -5
double -4.5
int -4
double -5.0
None of the above.

More Java Programming QUESTIONS AND ANSWERS available in next pages

    Health is the greatest gift, contentment is the greatest wealth -Buddha
The only place where success comes before work is in the dictionary.- Vidal Sassoon