Java Programming Questions & Answers: part18



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

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

1.What is the output of the following code? class SpecialArithmetic { public static void main (string args[]) { int x=17,a,b; a=x++;b=++x; System.out.println(“x=” + x +“a=” +a); System.out.println(“x=” + x + “b=” +b); a=x--;b=--x; System.out.println(“x=” + x + “a=” +a); System.out.println(“x=” + x + “b=” +b); } }

x=18 a=17
b=19
a=19
b=17
x=19 a=17

2.The method getAccountType() is invoked in the code for printBalance(). #276. The method getAccountType() is invoked in the code for printBalance(). What is the compile-time type of the receiver of this method invocation?

Object
Account
OverdraftAccount
The answer varies depending on how printBalance() is invoked
AccountType.

3.What is the output of the following code? class Bitwise { public static void main (string args[]) { int x=5, y=6; System.out.println(“x&y=” +(x &y)); System.out.println(“x|y=” +(x|y)); System.out.println(“x^y=” +(x^y)); } }

x&y=5x|y=7x^y=3
x&y=4x|y=7x^y=3
x&y=6x|y=7x^y=3
x&y=4x|y=8x^y=3
x&y=4

4.What is the size of the Short integer type in terms of bits?

8
16
32
64
128.

5.Given the code below: class A { public void print() { System.out.println("hi"); } } class B extends A { public void print() { System.out.println("bye"); } } B b = new A(); b.print();

Prints nothing
Prints “hi”
Prints “bye”
The code does not compile, the compiler returns a type error
The code throws a runtime exception.

More Java Programming QUESTIONS AND ANSWERS available in next pages

    Health is the greatest gift, contentment is the greatest wealth -Buddha
Too many of us are not living our dreams because we are living our fears.- Les Brown