Q73.Given an object created by the following class
3 \1 `' Q) N5 P 1. class Example extends Object {! A0 n+ L7 h3 ]; s2 a0 K2 k- h
2. public void Increment (Integer N) {
( y# A# P- q4 _ 3. N = new Integer( N.intValue() + 1);
0 J z2 i2 O( F5 g+ D/ e, T( \ 4. }1 m) T+ S8 s* c0 t- o
6. public void Result(int x) {
3 u4 J8 D% l; X+ H% R1 y 7. Integer X = new Integer(x);& T/ F5 q9 w2 e( ]% j, ]
8. Increment(X);
0 B5 [# E+ A! u2 | K 9. System.out.println(“New value is” + X);% A4 X1 |. m9 C& U+ x/ X' s
10. }
# F: B: k' H5 N( Q# |& ^ 11. }
& W- S( n; F8 J; t0 ?# j$ f7 e* p What happens when a program calls the Result method with a value of 30?
$ h" t( |6 [# j a. The message “New value is 31” goest to the standard output.
; x! e) s% r" k4 s$ W- y b. The message “New value is 29” goes to the standard output.$ W& Q$ h, T2 S; @ j' d
c. The message “New Value is 30” goes to the standard output.: _" o0 i) B0 y& B
d. The program fails to compile.( J5 ^, h0 ^8 L7 T; B {8 K. r
Q74.What is the output of the following program
. e" o: H! i! w+ O: O0 y9 c7 L 1. public class Test {
2 k: W$ V& `' ?2 o* F 2. private int i = giveMeJ();0 [9 w, l# G; B* t w/ |
3. private int j = 10;
) |8 u( H% z9 ~' B+ u0 ` 4.
& Y( @% w) J3 V 5. private int giveMeJ() {1 t" F1 p# F8 D4 ~' U. d
6. return j;
3 ^5 | B$ ^* @7 d1 S) ~ 7. }$ q0 S1 G/ P! E, C) C- ~! a8 L! {5 t
8.( Y# [8 j; G- M0 f& h: O
9. public static void main(String args[]) {9 Z \* g2 K( d
10. System.out.println((new AQuestion()).i);
2 [ {$ W0 x9 P 11. }: J: Q; ~: ~0 ]5 V; O+ W' l, J2 f, Q* E
12. }: b! H9 e' }2 i: v" C4 X
Select one correct answer: `7 W0 h" f# |# p7 p" B
a. Compiler error complaining about access restriction of private variables of AQuestion.
" L- o0 V* T, d( w b. Compiler error complaining about forward referencing.8 E4 b- O" F: H* B, y H- v
c. No Compilation error - The output is 0;
2 |% g/ E4 U9 @8 i/ w( T6 z d. No Compilation error - The output is 10;1 Y! M! ?$ Z4 m g5 W) H/ i& A
Q75.What is the result of compiling the following program
$ I" G# R1 X1 Z* K2 o C' k- ^* h* } 1. public class Test {/ r+ s, A2 N8 n
2. public static void main(String args[]) {! n% H$ T W) D" V( j5 _
3. System.out.println(“Before Try”);" j# g0 W7 ?+ j" i
4. try {6 G6 `) C# j# ]' e
5. } catch(java.io.IOException t) {
, W- B3 c j& ]: R/ f) w& D: Q% d 6. System.out.println(“Inside Catch”);
) L: Q7 x5 F+ t- X. R+ U) E; ~ 7. }
7 v9 U) _* r- a% r& _ 8. System.out.println(“At the End”);
9 p+ n. n% i$ U- Q w, _! Z0 w 9. }# k5 F' a2 O6 ?9 S& e
10. }
& x' a& J- G( l Select one correct answer
% W9 W3 x# h5 j% s: a a. No Compilation Error.
2 ]' l) L; D8 z5 H: S b. Compiler error complaining about the catch block where no IOException object can ever be thrown.. M! h5 s2 L. } ]+ A7 P; g# W
c. Compiler error - IOException not found. It must be imported in the first line of the code.
- ^1 K) X! v* R; j d. No compiler error. The lines “Before Try” and “At the end” are printed on the screen. k" Y0 P) ]* R: W) ^
73. c
$ H1 W% d% N3 V9 z. K" w3 f 74. c
2 ]) A' V g* z 75. b |