Java Programming Questions & Answers: part7



Software Programming : Java Programming QUESTIONS AND ANSWERS :: part7 : 11 to 15

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

11.Given the following source code, which comment line can be uncommented without introducing errors? abstract class MyClass { abstract void f(); final void g() {} // final void h() {} // (1) protected static int i; private int j; } final class MyOtherClass extends MyClass {// MyOtherClass(int n) { m = n; } //(2) public static void main(String[] args) { MyClass mc = new MyOtherClass(); } void f() { } void h() { } // void k() { i++; } // (3) // void l() { j++; } // (4) int m;}

(1)
(2)
(3)
(4)
None of the above.

12.Which of the following is true?

If an exception is uncaught in a method, the method will terminate and normal execution will resume
An overriding method must declare that it throws the same exception classes as the method it overrides
The main() method of a program can declare that it throws checked exceptions
finally blocks are executed if, and only if, an exception gets throws while inside the corresponding try block
None of the above.

13.What would be the result of attempting to compile and run the following program? class MyClass { static MyClass ref; String[] arguments; public static void main(String[] args) { ref = new MyClass(); ref.func(args); } public void func(String[] args) { ref.arguments = args; } }

The program will fail to compile, since the static method main() cannot have a call to the non-static method func()
The program will fail to compile, since the non-static method func() cannot access the static variable ref
The program will fail to compile, since the argument args passed to the static method main() cannot be passed on to the non-static method func()
The program will compile, but will throw an exception when run
The program will compile and run successfully.

More Java Programming QUESTIONS AND ANSWERS available in next pages

    Health is the greatest gift, contentment is the greatest wealth -Buddha
A real entrepreneur is somebody who has no safety net underneath them. Henry Kravis