You are on page 1of 6

Examen Core Java C

By Luis Ortega
October 13, 2008

Nombre:

1) How data structures can be visualized?


a) As a set of interfaces
b) Data in the form of a binary tree
c) None of the above
d) As containers that group multiple elements and represent them as a single
entity Vol 8 U 1 p 2
2) Where is located the collection Framework in java?
a) Java.lang
b) Java.io
c) Java.util p3
d) Java.collection
3) Which one enables programmers to assign one type of collection to another?
a) Cloneable
b) Serializable
c) Collection p4
d) Set
4) Select the options that provide order of their elements?
a) HashSet
b) TreeSet p9
c) Set
d) HashMap
5) Can a vector store primitive data types?
a) True
b) False p14
6) Select the collections that are dynamically resizable
a) ArrayList p15
b) LinkedList
c) Hashtable
d) HashMap
7) What does Collections class provides?
a) Sorting, finding min value, searching, copyng
b) Reversing, finding max value, copying, sorting
c) shuffing, Finding min value, sorting, searching
d) Sorting, finding max value, reversing, searching p30
8) What would this print out?
….

String objectArray[] = new String[] {“MAT”,”CAT”,”BAT”,”BALL”}; a) List

System.out.println(“List values are : ” + Arrays.asList(objectArray));

values are : [BALL,BAT,CAT,MAT]


b) List values are : [MAT,CAT, BAT,BALL]
c) List values are : [MAT,CAT,BAT,BALL] p33
d) None of the above
9) Which sentences are true?
a) The Statement object aggregates the ResultSet object V8 U3 p44
b) The application derives data from the ResultSet object
c) The DriverManager loads the required driver directly
d) All of the above
10)About drivers for JDBC, select the correct statements…
a) JDBC-ODBC Driver are referred as bridge drivers because they don’t
communicate directly with database p44,45,46
b) Net-Protocol Drivers use JNI and middleware
c) Native-API drivers and Native-Protocol drivers are pure Java drivers
d) None of the above
e) A,B and C
11)It isn’t possible to load a JDBC driver at any point of program execution, only at
the beginning
a) False
b) True p47
12)Which one is the correct to search a suitable driver that were loaded at the
initialization stage?
a) DriverManager.loadConnection(databaseURL, user, pass);
b) DriverManager.getConnection(databaseURL, user, pass); p48
c) DriverManager.setConnection(databaseURL, user, pass);
d) DriverManager.initializeConnection(databaseURL, user, pass);
13)Select the ones that aren’t true
a) The statement interface returns the number of rows in case of UPDATE
b) The method executeQuery() of Statement execute an SQL statement that
returns a single ResultSet object
c) The statement interface doesn’t returns the number of rows in case of
DELETE p49
d) The method executeQuery() of Statement execute an SQL statement that
returns multiple ResultSet objects
e) All of the above
f) None of the above
14)Method to iterate through a ResultSet
a) next() p50
b) getNext()
c) fetchNext()
d) none of the above
15)Whats the best way to retrieve data from the a resultset row?
a) resultSet.getInt(1); p52
b) resultSet.getString(“price”);
16)What is ResultSetMetaDAta?
a) It’s a class that provides information about tables
b) It’s a interface that provides methods to obtain information of a Connection
object
c) It’s a class that provides information about ResultSet objects
d) It’s a interface that provides information about ResultSet objects p62
e) It’s a class that provides information about Connection objects
f) It’s a interface that provides information about Connection objects
17)Order to be followed for a database URL is ?
a) Hostname, protocol,subname
b) Hostname,protocol,subprotocol
c) Protocol,subprotocol,subname p72
d) Subprotocol,protocol,hostname
18)Which one does the getColumnCount() method belongs to
a) ResultSetMetaData
b) ResultSet p73
c) DatabaseMetaData
d) None of the above
19)Which one is a correct prepared statement?
a) Stmt= conn.prepareStatement(“INSERT INTO tableName (col1,col2) VALUES
(?,?)”); V8 U5 p80
b) Stmt= conn.prepareStatement(“INSERT INTO tableName VALUES (?,?) OF
(col1,col2))”);
c) Stmt= conn.prepareStatement(“INSERT INTO tableName (col1,col2) VALUES
(?)”);
d) Stmt= conn.prepareStatement(“INSERT INTO tableName (col1,col2) VALUES
(“300”,”400”)”);
20)In a prepared statement we can…
a) Specify the values for the time of creation of the object
b) Construct statements once, run many p79,80
c) Call the execution with the method call()
d) Use placeholders to substitute later with values
21)Select the ones that are true about preparedStatements and stored procedures
a) Prepared statement is created and sent to the server to the server with a
placeholder for inputs
b) Store procedure is invoked like a normal function
c) Stored procedure binds input and output parameters
d) With stored procedures programmers need to know only call-level interface to
DB
e) None of the above
f) All of the above p84
22)How do we call a stored procedure?
a) Conn.execute(“{call PROCEDURENAME (?)}”);
b) Conn.prepareCall(“{call PROCEDURENAME (?)}”); p87
c) Conn.prepareCall(“{call PROCEDURENAME (100)}”);
d) Conn.execute(“{call PROCEDURENAME (100)}”);
23)How do you register an out parameter in a Callable statement
a) Cstmt.registerOutParameter(3,string);
b) Cstmt.registerOutParameter(java.sql.Types.VARCHAR);
c) Cstmt.registerOutParameter(java.sql.Types.VARCHAR,3);
d) Cstmt.registerOutParameter(2,java.sql.Types.VARCHAR); p88
e) Cstmt.registerOutParameter(string,3);
24)In stored procedures theres only in and out parameters
a) True
b) False p84
25)Select functionalities of JDBC
a) Transaction management
b) Cursor support
c) Multiple result set processing
d) None of above
e) All of above p92
26)The creation of a stored procedure isn’t specific for every different DBMS.
a) True
b) False
27)About transaction management, specifically rollbacking, which ones are true
a) Rollback itself can throw a SQL exeption p94
b) Its enough to put rollback anywhere in the code to avoid problems of
exceptions of SQL
c) Rollback goes in a try block
d) You should put the rollback in a catch statement
28)About cursor support, which ones are true
a) All drivers for JDBC support it
b) There can be always movement enabled for every cursor
c) Cursors support arguments type of result set and Concurrency of result set
102
d) A type of result set SCROLL_INSENSITIVE could be susceptible to changes
made by others
29)Where are defined support clases for JDBC
a) Javax.sql
b) Java.sql.support
c) Java.sql p80
d) Javax.sql.support
30)What is the class variable maintained by java.sql.Types for integers
a) Int
b) INT
c) INTEGER p110
d) Integer
31)Which of the following is correct syntax for creating a stored procedure?
a) CREATE PROCEDURE procName begin SELECT * FROM table end;
b) CREATE PROCEDURE procName() begin end; p110
c) CREATE PROCEDURE AS procName SELECT * FROM table
d) None of above
32)Why is it useful the reflection API
a) Determine the class of an object during run time
b) Get complete info about a class, such as methods, constructors, super
clases….
c) Invoke methods at runtime
d) All of the above V8 U7 p116
33)Which one is the super class of all clases in java
a) Java.lang
b) Java.lang.object p116
c) Java.super
d) Java.lang.class
34)Select all the correct ways of creating the Class object (something that
represents the class name) This object its provided Car mycar;
a) Class cl = mycar.Class();
b) Class cl = mycar.getClass(); p 118
c) Class cl = mycar.Class;
d) Class cl = Class.forName(strName);
35)The reflective API of Java says that primitive data types and void keyword cannot
be represented in form of Class object, is this true?
a) Of course
b) Are you kidding me! Totally no 118
36)Select some methods available for a Class object
a) isInterface() p119
b) setMethods()
c) getFields()
d) getModifiers()
e) All of the above
37) Import java.lang.reflect.*;
You Class GrandFather{};
Class Father extends GrandFather{};
Class Son extends Father {};
Public static void main(String[] a){
Son myson = new Son();
Class cl = myson.getClass();
Class superclass = cl.getSuperClass();
Int i=0;
while(superclass != null){
System.out.println(“Hierarchy : ” + i++ + “ ”+ superclass.getName());
Superclass = superclass.getSuperclass();
}
}

have this snippet of code, select the output to screen


a) Hierarchy : 1 Father / Hierarchy : 2 GrandFather / Hierarchy : 3
java.lang.object p120, 121
b) Hierarchy : 1 Father / Hierarchy : 2 GrandFather
c) Hierarchy : 1 Son / Hierarchy : 2 Father / Hierarchy : 3 GrandFather
d) None of the above
38)The getMethods method can be used to retrieve private methods available in a
class
a) False p119
b) True
39)Which method(s) can we use to find if the returned value of getModifiers method
represesents public and final at the same time
a) isPublic()
b) isFinal()
c) isPublicFinal()
d) A and B p143
40)Which following classes does java.lang.reflect.AccesibleObject is superclass of?
a) Field
b) Class
c) Constructor p122
d) Method
41)Through the Field Class its possible to…
a) Find values of fields
b) Find or modify the values of fields p126
c) Modify the values of fields
d) None of the above

You might also like