Oracle job sample paper 4
16. What is the output of the following program
class questionC {
int a;
public int c;
private int c;
void setc(int i) {
c = i;
}
int getc() {
return c;
}
}
class printQuestionC {
public static void main ( String args[ ] ) {
questionC qc = new questionC( );
qc.a = 10;
qc.b = 20;
qc.c = 100;
qc.b = qc.a + qc.c;
System.out.println ( "a, b and c : " + qc.a + ", " + qc.b + ", " + qc.getc());
}
}
(A) a, b and c : 10, 20, 100
(B) a, b and c : 10, 110, 100
(C) a, b and c : 10, 110,
(D) The code does not compile.
17. Which of the following is not true about serialization
(A) Only an object that implements the Serializable interface can be saved and restored
(B) The Serializable interface defines no members
(C) transient variables can be saved by the serialization facilities
(D) static variables are not saved by the serialization facilities
18. What is the output of the following program ?
class Promote {
public static void main ( String args[ ] ) {
byte b 42;
char c = 'a';
short s = 1-24;
int i = 50000;
float f = 5.67 f;
double d = .1234;
double resuot = (f * b) + (i / c) - (d * s);
System.out.println("Result = " + result);
}
}
(A) The code does not compile.
(B) The final result of the expression is a double
(C) The final result of the expression is a float
(D) The final result of the expression is an int
19. Consider the following Java Code
public class Alias {
int i;
Alias(int ii) { i = ii; }
public static void main ( String [ ] args ) {
Alias x = new Alias(7);
Alias1 y = x;
System.out.println("x : " + x.i);
System.out.println("y : " + y.i);
x.i++;
System.out.println("x : " + x.i);
System.out.println("y : " + y.i);
}
}
What will be the output ?
(A) The code does not compile
(B) The code compiles but gives runtime exception
(C) x = 7
y = 7
x = 8
y = 7
(D) x = 7
y = 7
x = 8
y = 8
Tuesday, April 29, 2008
Oracle job sample paper 4
Posted by msnprabu at 11:34 PM
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment