Java Programming Questions & Answers: part12



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

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

6.Suppose you define a Java class as follows: public class Test { } In order to compile this program, the source code should be stored in a file named

Test. class
Test.doc
Test.txt
Test. java
Any name with extension .java.

7.To declare a constant MAX_LENGTH as a member of the class, you write

Final static MAX_LENGTH = 99.98;
Final static float MAX_LENGTH = 99.98;
Static double MAX_LENGTH = 99.98;
Final double MAX_LENGTH = 99.98;
Final static double MAX_LENGTH = 99.98;.

8.Which of the following statement is not true?

A default no-arg constructor is provided automatically if no constructors are explicitly declared in the class
At least one constructor must always be defined explicitly
Constructors do not have a return type, not even void
Constructors must have the same name as the class itself
Constructors are invoked using the new operator when an object is created.

9.What is the printout for the second statement in the main method? public class Foo { static int i = 0; static int j = 0; public static void main(String[] args) { int i = 2; int k = 3; { int j = 3; System.out.println("i + j is " + i + j); } k = i + j; System.out.println("k is " + k); System.out.println("j is " + j); } }

k is 0
k is 1
k is 2
k is 3
k is -1.

10.Assume int[] scores = {1, 20, 30, 40, 50}, what value does java.util.Arrays.binarySearch(scores, 3) return?

0
-1
1
2
-2.

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