Java Programming Questions & Answers: part9



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

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

1.The Java expression: ! ((b != 0) || (c <= 5)) is equivalent to:

(! (b = 0)) && (! (c > 5))
(b == 0) && (c > 5)
(b != 0) && (c <= 5)
! ((b <> 0) && (c <= 5))
(b == 0) && (c <= 5).

2.The Java program: public class Practice2 { public static void main(String args[]) { for(int row = -2; row <= 2; row++) { for(int col = -2; col <= 2; col++) if( col*col < row*row) System.out.print("* "); else System.out.print(". "); System.out.println(); } } } will produce which one of the following patterns when it is executed?

. . . . .
. .
* .
. .
. .

3.Suppose static void nPrint(String message, int n) { while (n > 0) { System.out.print(message); n--; } } What is the printout of the call Print('a', 4)?

aaaaa
aaaa
aaa
aa
invalid call.

4.Analyze the following code: public class Test { public static void main(String[] args) { int[] oldList = {1, 2, 3, 4, 5}; reverse(oldList); for (int i = 0; i < oldList.length; i++) System.out.print(oldList[i] + " "); } public static void reverse(int[] list) { int[] newList = new int[list.length]; for (int i = 0; i < list.length; i++) newList[i] = list[list.length - 1 - i]; list = newList; } }

The program displays 1 2 3 4 5
The program displays 1 2 3 4 5 and then raises an ArrayIndexOutOfBoundsException
The program displays 5 4 3 2 1
The program displays 5 4 3 2 1 and then raises an ArrayIndexOutOfBoundsException
The program displays 54321 and doesnot raise an arrayIndexOutOfBoundsException.

5.If n were declared to be an int and were assigned a non-negative value, the statement: if (n / 10 % 10 == 3) System.out.println("Bingo!"); will display the message if and only if:

n is divisible (divides evenly) by 3
n is divisible (divides evenly) by 30
The units' digit (also known as the 1's place) of n is 3
The tens' digit of n is 3
The remainder when n is dividied by 30 equals 3.

More Java Programming QUESTIONS AND ANSWERS available in next pages

    Health is the greatest gift, contentment is the greatest wealth -Buddha
If your ship doesn’t come in, swim out to meet it!-Jonathan Winters