Java Programming Questions & Answers: part9



Software Programming : Java Programming QUESTIONS AND ANSWERS :: part9 : 6 to 10

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

6.What is Math.rint(3.5)?

3.0
3
4
4.0
5.0.

7.Which of the following is not the reserved words in java? #125. Which of the following is not the reserved words in java?

Public
Static
Void
Class
Num.

8.Analyze the following code. public class Test { public static void main(String[] args) { System.out.println(m(2)); } public static int m(int num) { return num; } public static void m(int num) { System.out.println(num); } }

The program has a syntax error because the two methods m have the same signature
The program has a syntax error because the second m method is defined, but not invoked in the main method
The program runs and prints 2 once
The program runs and prints 2 twice
The program runs and prints 2 thrice.

9.Analyze the following code. public class Test { public static void main(String[] args) { System.out.println(max(1, 2)); } public static double max(int num1, double num2) { System.out.println("max(int, double) is invoked"); if (num1 > num2) return num1; else return num2; } public static double max(double num1, int num2) { System.out.println("max(double, int) is invoked"); if (num1 > num2) return num1; else return num2; } }

The program cannot compile because you cannot have the print statement in a non-void method
The program cannot compile because the compiler cannot determine which max method should be invoked
The program runs and prints 2 followed by "max(int, double)" is invoked
The program runs and prints 2 followed by "max(double, int)" is invoked
The program runs and prints "max(int, double) is invoked" followed by 2.

10.negatate each of the 2 subexpressions; #3. change the && to || or || to &&. #136. Suppose a method signature looks like this: public static void Check(char c, Funny f) { ... } Which one of the following calls to method Check() could possibly be syntactically valid?

Check("a", x);
Check(97, x);
Check(sweat(a[3]), x);
Check(char q, Funny p);
Check(Funny p, char q);.

More Java Programming QUESTIONS AND ANSWERS available in next pages

    Health is the greatest gift, contentment is the greatest wealth -Buddha
Failure defeats losers, failure inspires winners.-Robert T. Kiyosaki