Oracle Sample Placement Paper 3
December 31, 2007
Oracle Sample Placement Paper 3
1. What is the output of the following program
main()
{
int i = 5;
printf(“%d\n”, i++ * i–);
}
(A) 25
(B) 24
(C) 20
(D) 30
2. What is the output of the following program
main()
{
char ch=’a';
printf(“%d “,ch);
printf(“%d\n”,((int)ch)++);
}
(A) 97 98
(B) 97
(C) 97 97
(D) compilation error
3. What does the following program do ?
int main()
{
int i;
int array1[10], array2[10] ;
int *ep, *ip2 = &array2[0];
int *ip1 = &array1[0];
for(ep = &array1[9]; ep >= ip1; ep–)
*ep = *ip2++ ;
}
(A) copies array1 to array2
(B) copies array2 to array1
(C) copies array1 to array2 in reverse order
(D) copies array2 to array1 in reverse order
4. what does the following program do ?
#include
int main()
{
char string[100];
char *p;
gets(string);
for(p = string; *p != ‘\0′; p++)
;
printf(“%d”, p – string);
}
(A) prints the memory used by “string”
(B) prints the character values of “string”
(C) prints the length of “string”
(D) errors out.
5. What is the output if the input to following program is,
INDIA DEVELOPMENT CENTRE
#include
int trail(char *line, int max);
main()
{
char p[100];
printf(“%d”,trail(p,10));
}
int trail(char *line, int max)
{
int nch = 0;
int c;
max = max – 1;
while((c = getchar()) != EOF)
{
if(c == ‘\n’)
break;
if(nch 0)
recurse(u-1);
printf(“%d “,u);
}
(A) 1 2 3 4 5
(B) 5 4 3 2 1
(C) 0 1 2 3 4 5
(D) 5 4 3 2 1 0
12. What is the output of the following program
#include
void main()
{
void assign(int[]);
int i[5],a=0;
for (a = 0;a (100,10000),( 200,20000),(300,30000)
(B) (Empno,Sal) -> (100,10000),(200,20000),(300,3000)
(C) Error : “Use of Where Current of Restricted “
(D) Error : “Fetch Out of Sequence “
18. Consider the following PL/SQL code.
declare
v_char varchar2(3) := ‘ABCD’;
begin
dbms_output.put_line(‘Value of v_char ‘ || v_char);
exception
when others then
dbms_output.put_line(‘Exception Captured’);
end;
/
What is the output ?
(A) “Value of v_char ABCD”
(B) “Exception Captured”
(C) ORA-06502: PL/SQL: numeric or value error
(D) ORA-1458-invalid length inside variable character string
19. Consider the following PL/SQL Code
declare
empno emp1.empno%type ;
begin
select empno
into empno
from emp1
where sal > 1000
and rownum (100,1000,200,3000,300,4000)
(B) (Empno,Sal) -> (100,1000),(200,3000),(300,3000)
(C) (Empno,Sal) -> (100,2000),(200,3000),(300,4000)
(D) Error: Invalid usage of variable name which is same as column name
20. Consider the following PL/SQL Code
Create or replace procedure Test_Proc(
p_empno in number ,
p_dno in number ,
p_sal in out number ) is
v_tempvar number ;
begin
if p_sal
dbms_output.put_line (l_var);
END IF;
END;
Which of the following statements is correct?
(A) Usage of labels is invalid in PL/SQL.
(B) GOTO cannot branch into an IF statement
(C) GOTO is not a valid syntax.
(D) (A) and (C) are correct statements.
23. Consider the following PL/SQL block.
DECLARE
l_var1 NUMBER := &a;
l_var2 NUMBER := &b;
Data_problem EXCEPTION;
BEGIN
BEGIN
IF (l_var1 > l_var2) THEN
RAISE NO_DATA_FOUND;
ELSE
RAISE Data_Problem;
END IF;
EXCEPTION
WHEN NO_DATA_FOUND THEN
dbms_output.put_line (‘No Data’);
WHEN Data_Problem THEN
RAISE Data_problem;
END;
EXCEPTION
WHEN Data_problem THEN
dbms_output.put_line (‘Data Problem’);
END;
Identify which of the following statements is/are correct.
(A) Output printed is ‘No Data’ when a > b .
(B) Exception cannot be used to move from inner to outer block.
(C) Output printed is ‘Data Problem’ when b > a .
(D) Statements A and C are correct.
24. Employee table has records of 10 employees.
Execution of the following PL/SQL block given below will result in :
DECLARE
CURSOR C1 IS
SELECT name, basic+hra salary
FROM employee ;
Incentive NUMBER;
l_name VARCHAR2(30);
l_salary NUMBER;
BEGIN
LOOP
Fetch c1 INTO l_name, l_salary;
EXIT WHEN c1%NOTFOUND OR
c1%ROWCOUNT = 9 ;
Incentive := l_salary * 0.1 ;
END LOOP;
close c1;
dbms_output.put_line (‘Name – ‘ || l_name);
dbms_output.put_line (‘Incentive =’ || Incentive);
END;
(A) Error as alias cannot be used in cursor.
(B) Name & Incentive of nine employees will be printed.
(C) Error as %NOTFOUND & %ROWCOUNT cannot be used with explicit cursors.
(D) Error – Invalid cursor
25. Consider the procedure given below:
PROCEDURE calc_bonus (salary IN INTEGER, gross_salary IN OUT NUMBER,
bonus OUT NUMBER) IS
BEGIN
IF (salary > 1000) THEN
bonus := Salary * .1 ; — statement 1
ELSE
salary := Salary * 2; — statement 2
bonus := salary * 0.1 ; — statement 3
END IF;
gross_salary := Salary * 2 ; — statement 4
END;
(A) No errors are there in the PL/SQL block
(B) Statements 1 and 3 will result in error.
(C) Statement 2 will result in error.
(D) Statements 1, 2 and 3 will result in error.
26. Consider the following data
TABLE A TABLE B
COL1 COL1
—— ——-
10 15
20 20
30 25
40 30
50 35
60 40
70 45
80 50
10 35
100 60
65
30
80
90
100
select count(*)
from (select A1.col1 col1
from A A1, A A2
where A1.col1 = A2.col1
UNION ALL
select A.col1 col1
from A, B
where A.col1(+) = B.col1 );
What would be output of the above SQL query?
(A) 25
(B) 27
(C) 29
(D) error
27. Consider the following DDL
create table emp(
empno number,
name char(30),
sal number,
deptno number,
manager number)
create table dept(
deptno number,
name char(30),
location char(30))
i) create view view1 as
select location, count(empno) emp_count
from emp, dept
where emp.deptno = dept.deptno
group by location;
ii) create view view2 as
select empno, name, location
from emp, dept
where emp.deptno = dept.deptno;
iii) create view view3 as
select *
from emp, dept;
Which is the correct view definition ?
(A) i
(B) i and ii
(C) ii and iii
(D) All
28. What is the output of the SQL statement
select floor((ceil(-0.42) – abs(round(-0.64)))/2) from dual;
(A) -2
(B) -1
(C) 0
(D) 1
29. Consider the following data
Table STUDENT
Name subject status
———– ————— ——–
Student1 Sub1 P
Student1 Sub2 F
Student2 Sub1 P
Student3 Sub2 F
Student4 Sub1 F
Student4 Sub2 P
Student5 Sub1 P
Student5 Sub2 P
Student6 Sub1 F
Student6 Sub2 F
i) select * from student
where status = ‘P’ OR status = ‘F’ AND subject = ‘Sub1′;
ii) select * from student
where (status = ‘P’ OR status = ‘F’) AND subject = ‘Sub1′;
iii) select * from student
where subject = ‘Sub1′ AND status = ‘P’ OR status = ‘F’;
iv) select * from student
where status = ‘P’ OR (status = ‘F’ AND subject = ‘Sub1′);
Which statements would produce same output
(A) i & ii
(B) ii & iii
(C) iii & iv
(D) i & iv
30. Consider the following DML operation along with table data from above question
i) update student s1
set s1.status = ‘P’
where s1.subject =
( select distinct(s2.subject)
from student s2
where s1.name = s2.name );
ii) delete from student s1
where status > ‘F’
and s1.name not in
( select s1.name
from student s2
where s2.subject = ‘Sub2′);
iii) update student s1
set s2.status = ‘P’
where s1.subject in
( select s2.subject
from student s2
where s2.status = ‘F’);
Which statement(s) are incorrect/errors out:
(A) i & ii
(B) ii & iii
(C) i & iii
(D) i, ii & iii
Answers:a,d,d,c,d,c,d,c,a,a,c,b,b,d,a,b,d,c,c,b,c,b,d,d,c,b, a,b,d,c
———————————————————— ——————————–
1. What is the output of the following program
class ExceptionClass1 extends Error {
public String toString() {
return “ExceptionClass1″;
}
}
class ExceptionClass2 extends Exception {
public String toString() {
return “ExceptionClass2″;
}
}
public class ExceptionClassesTest {
private static final int CLASS1 = 10;
private static final int CLASS2 = 20;
public static void main( String[] args ) {
int param = Integer.parseInt(args[0]);
try {
exceptionClassTest( param );
}
catch(Throwable t) {
System.out.println(“” + t );
}
}
public static void exceptionClassTest(int param) throws ExceptionClass2 {
try {
if( param == CLASS1 ) throw new ExceptionClass1();
if( param == CLASS2 ) throw new ExceptionClass2();
}
catch( Exception ex ) {
System.out.println(“” + ex );
throw (ExceptionClass2)ex;
}
}
}
main()
{
int i = 5;
printf(“%d\n”, i++ * i–);
}
If you compile the above program and do the following, what is the output ?
1. java ExceptionClassesTest 10
2. java ExceptionClassesTest 20
3. java ExceptionClassesTest 30
(A) Cannot do the above because the program will give compilation error ‘unreported exception java.lang.ExceptionClass1; declared to be thrown’
(B) ExceptionClass1( twice ), ExceptionClass2 ( twice ), No output
(C) ExceptionClass1( once ), ExceptionClass2( twice ), No output
(D) Cannot do the above because the program will give compilation error ‘incompatible types found : ExceptionClass1, required: java.lang.Throwable’
2. When trying to establish a JDBC connection, it fails with the message “Driver not found”.
This is due to
(A) The DriverManager class is not found
(B) The JDBC driver is not registered
(C) The JDBC driver does not exist in the CLASSPATH
(D) The Connection class is not found
3.
public class Select {
public static void main (String args[]) {
String url = “jdbc:oracle://Carthage.imaginary.com/ora”;
Connection con = null;
try {
String driver = “com.imagiary.sql.oracle.OracleDriver”;
Class.forName(driver).newInstance();
}
catch (Exception e) {
System.out.println(“Failed to load Oracle Driver.”);
return;
}
try {
con = DriverManager.getConnection(url, “borg”, “”);
Statement select = con.createStatement();
ResultSet result = select.executeQuery(“SELECT DATE_OF_JOINING from EMP”);
While (result.next()) {
System.out.println(“The date of joining is ” + result.getString(1));
}
}
}
}
Note: the column DATE OF JOINING is not null and it always has a value.
What would be the output of this code?
(A) This code does not compile
(B) “The date of joining is 01-JUN-1999″. (The sample date fetched by the SQL stmt)
(C) The code complies but results in run-time exception
(D) “The date of joining is “. ( The date is null)
4. As far as handling null values in JAVA and SQL is concerned which of the following statements is wrong?
(A) For Java Objects SQL NULL maps to JAVA NULL
(B) While using the method getInt( ), the JAVA NULL maps the SQL NULL
(C) a Java ResultSet has no way of representing a SQL NULL value for any numeric SQL column
(D) Call to getInt() could return some driver attempt at representing NULL, most likely 0.
5. As per the JDBC Specification for SQL to Java Datatype Mappings, which of the following statements is correct?
(A) The SQL datatype FLOAT maps to the Java datatype float
(B) The SQL datatype FLOAT maps to the Java datatype long
(C) The SQL datatype FLOAT maps to the Java datatype double
(D) The SQL datatype FLOAT maps to the Java datatype int
6. Which of the following is not valid array declarations/definitions?
(A) int iArray1[10];
(B) int iArray2[];
(C) int iArray3[] = new int[10];
(D) int []iArray5 = new int[10];
7. As per the JDBC Specification for Java to SQL Datatype Mappings, which of the following statements is correct?
(A) The Java datatype float maps to the SQL datatype REAL
(B) The Java datatype float maps to the SQL datatype DOUBLE
(C) The Java datatype float maps to the SQL datatype INTEGER
(D) The Java datatype float maps to the SQL datatype SMALLINT
8. Which of the following is a legal return type of a method overloading the following method:
public void add(int a) { …. }
(A) void
(B) int
(C) Can be anything
(D) short
9. Which of the following is not one of the methods for the class DriverManager?
(A) static public synchronized Connection getConnection ( String url, Properties info) throws SQLException
(B) static public synchronized Connection getConnection ( String url,Strng user, String password) throws SQLException
(C) static public synchronized Connection getConnection ( String url ) throws SQLException
(D) static public synchronized Connection getConnection ( String url, Strng user, String password, Properties info) throws SQLException
10. Which of the following is false with respect to updateable result sets
(A) The select should pertain to a single table and should include the primary key columns
(B) JDBC drivers are not required to support updateable result sets
(C) If the driver does not support updateable result set, it will always throw an exception
(D) If the driver does not support updateable result set, it will issue a SQLWarning and assigns the result set to a type it can support.
11. Which of the following is not true about jsp:forward
(A) This allows the request to be forwarded to another JSP, a servlet or a static resource.
(B) The resource to which the request is being forwarded should be in the same context as the JSP dispatching the request
(C) Execution in the current JSP stops when it encounters jsp:forward tag
(D) The output stream need not be buffered and it can contain some output written to it.
12. A session has been created by the client. If the client does not continue the session within a specified time, which of the following will not happen
(A) the server will expire the session and delete all data associated with the session
(B) the server will expire the session but the data associated with the session are retained
(C) The session key is invalidated
(D) The old session key is not associated with any session
13. What is the output of the following program
class getBoolValues {
public static void main (String args[]) {
boolean a = true;
boolean b = false;
boolean c = a ^ b;
boolean d = (!a & b) | (a & !b)
System.out.println(” a ^ b = ” + c);
System.out.println(” !a&b|a&!b = ” + d);
}
}
(A) The code does not compile.
(B) a ^ b = true
!a&b|a&!b = true
(C) The code compiles but raises an exception during runtime.
(D) a ^ b = true
!a&b|a&!b = false
14. What is the output of the following program
class questionA {
public static void main ( String args[] ) {
int i, k;
i = 10;
k = i 4) & 0xf ] + Que[ e & 0x0f ] );
}
}
(A) 0xf1
(B) 0xff
(C) 0xf0
(D) 0x0f
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
20. Consider the following Java Code
public class Test {
public static void main (String args []) {
int age;
age = age + 1;
System.out.println(“The age is ” + age);
}
}
What will be output of the above code?
(A) Compiles and runs with no output
(B) Compiles and runs printing out The age is 1
(C) Compiles but generates a runtime error
(D) The code does not compile
21. What is the result of the executing the following code, using the parameters 4 and 0 ?
public void divide(int a, int b) {
try {
int c = a / b;
} catch (Exception e) {
System.out.print(“Exception “);
} finally {
System.out.println(“Finally”);
}
}
(A) Prints out: Exception Finally
(B) Prints out: Finally
(C) Prints out: Exception
(D) No output
22. Consider the following Java code.
import java.util.*;
import java.sql.*;
public class t6{
public t6(){}
public t6(String temp){System.out.println(“In constructor of t6″+temp); }
public static long f(int n){
if (n 20
B. c > 0 && d 50
C. c > 1 && d 0
D. c 0 || d 7 && d 20
b. c > 0 && d 50
c. c > 1 && d 0
d. c 0 || d 7 && d 20
b. c > 0 && d 50
c. c > 1 && d 0
d. c 0 || d 4) & 0xf ] + Que[ e & 0x0f ] );
}
}
What is the output of the above code?
a) 0xf1
b) 0xff
c) 0xf0
d) 0x0f
Answer = d
Question 16:
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());
}
}
What is the output of the above code?
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.
Answer : d
Question 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
Answer : c
Question 18:
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);
}
}
What is the output of the above code?
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
Answer : b
Question 19:
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 is the output of the above code?
a) The code does not compile
b) The code givies runtime exception
c) x = 7
y = 7
x = 8
y = 7
d) x = 7
y = 7
x = 8
y = 8
Answer : d
Question 20:
public class Test {
public static void main (String args []) {
int age;
age = age + 1;
System.out.println(“The age is ” + age);
}
}
What will be output of the above code?
a) Compiles and runs with no output
b) Compiles and runs printing out The age is 1
c) Compiles but generates a runtime error
d) The code does not compile
Answer : d
Question 21:
What is the result of executing the following code, using the parameters 4 and 0:
public void divide(int a, int b) {
try {
int c = a / b;
} catch (Exception e) {
System.out.print(“Exception “);
} finally {
System.out.println(“Finally”);
}
}
a) Prints out: Exception Finally
b) Prints out: Finally
c).Prints out: Exception
d) No output
Answer : a
Question 22:
mport java.util.*;
import java.sql.*;
public class t6{
public t6(){}
public t6(String temp){System.out.println(“In constructor of t6″+temp); }
public static long f(int n){
if (n 4) & 0xf ] + Que[ e & 0x0f ] );
}
}
What is the output of the above code?
a) 0xf1
b) 0xff
c) 0xf0
d) 0x0f
Answer = d
Question 16:
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());
}
}
What is the output of the above code?
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.
Answer : d
Question 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
Answer : c
Question 18:
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);
}
}
What is the output of the above code?
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
Answer : b
Question 19:
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 is the output of the above code?
a) The code does not compile
b) The code givies runtime exception
c) x = 7
y = 7
x = 8
y = 7
d) x = 7
y = 7
x = 8
y = 8
Answer : d
Question 20:
public class Test {
public static void main (String args []) {
int age;
age = age + 1;
System.out.println(“The age is ” + age);
}
}
What will be output of the above code?
a) Compiles and runs with no output
b) Compiles and runs printing out The age is 1
c) Compiles but generates a runtime error
d) The code does not compile
Answer : d
Question 21:
What is the result of executing the following code, using the parameters 4 and 0:
public void divide(int a, int b) {
try {
int c = a / b;
} catch (Exception e) {
System.out.print(“Exception “);
} finally {
System.out.println(“Finally”);
}
}
a) Prints out: Exception Finally
b) Prints out: Finally
c).Prints out: Exception
d) No output
Answer : a
Question 22:
mport java.util.*;
import java.sql.*;
public class t6{
public t6(){}
public t6(String temp){System.out.println(“In constructor of t6″+temp); }
public stati
Related Posts
- Oracle Sample Placement Paper 1
- Yahoo sample placement Paper
- Logicsoft International Pvt Ltd (Oracle Developer )
- Perot Placement Paper and Pattern
- Oracle Sample Placement Paper 4
- Sonata Software – Oracle DBA
- Latest Placement Paper – Chennai – Birlasoft
- AppLabs Placement Paper Pattern
- Satyam Paper 26th March 2007
- Walkin Interview @ IBM in Bangalore on 3rd Nov 2007
- Latest Patni Placement Paper
- Oracle Placement Paper 13th May 2005 at Hyderabad
