Solutions Examen CORECd

8
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

description

Exam i compiled to study for IBM cert in Java. This questions cover Core-Java C CY420

Transcript of Solutions Examen CORECd

Page 1: Solutions Examen CORECd

Examen Core Java CBy Luis Ortega

October 13, 2008

Nombre:

1) How data structures can be visualized?a) As a set of interfacesb) Data in the form of a binary treec) None of the aboved) 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.langb) Java.ioc) Java.util p3d) Java.collection

3) Which one enables programmers to assign one type of collection to another?a) Cloneableb) Serializablec) Collection p4d) Set

4) Select the options that provide order of their elements?a) HashSetb) TreeSet p9c) Setd) HashMap

5) Can a vector store primitive data types?a) Trueb) False p14

6) Select the collections that are dynamically resizablea) ArrayList p15b) LinkedListc) Hashtabled) HashMap

7) What does Collections class provides?a) Sorting, finding min value, searching, copyngb) Reversing, finding max value, copying, sortingc) shuffing, Finding min value, sorting, searching

Page 2: Solutions Examen CORECd

d) Sorting, finding max value, reversing, searching p308) What would this print out?

a)a)a)a)a)

List values are : [BALL,BAT,CAT,MAT]b) List values are : [MAT,CAT, BAT,BALL]c) List values are : [MAT,CAT,BAT,BALL] p33d) None of the above

9) Which sentences are true?a) The Statement object aggregates the ResultSet object V8 U3 p44b) The application derives data from the ResultSet objectc) The DriverManager loads the required driver directlyd) 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,46b) Net-Protocol Drivers use JNI and middlewarec) Native-API drivers and Native-Protocol drivers are pure Java driversd) None of the abovee) A,B and C

11) It isn’t possible to load a JDBC driver at any point of program execution, only at the beginninga) Falseb) 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); p48c) DriverManager.setConnection(databaseURL, user, pass);d) DriverManager.initializeConnection(databaseURL, user, pass);

13) Select the ones that aren’t truea) 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 objectc) The statement interface doesn’t returns the number of rows in case of DELETE p49d) The method executeQuery() of Statement execute an SQL statement that returns multiple

ResultSet objectse) All of the abovef) None of the above

….

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

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

Page 3: Solutions Examen CORECd

14) Method to iterate through a ResultSeta) next() p50b) 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); p52b) resultSet.getString(“price”);

16) What is ResultSetMetaDAta?a) It’s a class that provides information about tablesb) It’s a interface that provides methods to obtain information of a Connection objectc) It’s a class that provides information about ResultSet objectsd) It’s a interface that provides information about ResultSet objects p62e) It’s a class that provides information about Connection objectsf) It’s a interface that provides information about Connection objects

17) Order to be followed for a database URL is ?a) Hostname, protocol,subnameb) Hostname,protocol,subprotocolc) Protocol,subprotocol,subname p72d) Subprotocol,protocol,hostname

18) Which one does the getColumnCount() method belongs toa) ResultSetMetaDatab) ResultSet p73c) DatabaseMetaDatad) None of the above

19) Which one is a correct prepared statement?a) Stmt= conn.prepareStatement(“INSERT INTO tableName (col1,col2) VALUES (?,?)”); V8 U5 p80b) 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 objectb) Construct statements once, run many p79,80c) 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 proceduresa) Prepared statement is created and sent to the server to the server with a placeholder for inputsb) Store procedure is invoked like a normal functionc) Stored procedure binds input and output parametersd) With stored procedures programmers need to know only call-level interface to DBe) None of the abovef) All of the above p84

Page 4: Solutions Examen CORECd

22) How do we call a stored procedure?a) Conn.execute(“{call PROCEDURENAME (?)}”);b) Conn.prepareCall(“{call PROCEDURENAME (?)}”); p87c) Conn.prepareCall(“{call PROCEDURENAME (100)}”);d) Conn.execute(“{call PROCEDURENAME (100)}”);

23) How do you register an out parameter in a Callable statementa) 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); p88e) Cstmt.registerOutParameter(string,3);

24) In stored procedures theres only in and out parametersa) Trueb) False p84

25) Select functionalities of JDBCa) Transaction managementb) Cursor supportc) Multiple result set processingd) None of abovee) All of above p92

26) The creation of a stored procedure isn’t specific for every different DBMS.a) Trueb) False

27) About transaction management, specifically rollbacking, which ones are truea) Rollback itself can throw a SQL exeption p94b) Its enough to put rollback anywhere in the code to avoid problems of exceptions of SQLc) Rollback goes in a try blockd) You should put the rollback in a catch statement

28) About cursor support, which ones are truea) All drivers for JDBC support itb) There can be always movement enabled for every cursorc) Cursors support arguments type of result set and Concurrency of result set 102d) A type of result set SCROLL_INSENSITIVE could be susceptible to changes made by others

29) Where are defined support clases for JDBCa) Javax.sqlb) Java.sql.supportc) Java.sql p80d) Javax.sql.support

30) What is the class variable maintained by java.sql.Types for integersa) Intb) INTc) INTEGER p110

Page 5: Solutions Examen CORECd

d) Integer31) 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; p110c) CREATE PROCEDURE AS procName SELECT * FROM tabled) None of above

32) Why is it useful the reflection APIa) Determine the class of an object during run timeb) Get complete info about a class, such as methods, constructors, super clases….c) Invoke methods at runtimed) All of the above V8 U7 p116

33) Which one is the super class of all clases in javaa) Java.langb) Java.lang.object p116c) Java.superd) 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 118c) 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 courseb) Are you kidding me! Totally no 118

36) Select some methods available for a Class objecta) isInterface() p119b) setMethods()c) getFields()d) getModifiers()e) All of the above

37) You have this snippet of code, select the output to screen

Import java.lang.reflect.*;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();

}}

Page 6: Solutions Examen CORECd

a) Hierarchy : 1 Father / Hierarchy : 2 GrandFather / Hierarchy : 3 java.lang.object p120, 121b) Hierarchy : 1 Father / Hierarchy : 2 GrandFatherc) Hierarchy : 1 Son / Hierarchy : 2 Father / Hierarchy : 3 GrandFatherd) None of the above

38) The getMethods method can be used to retrieve private methods available in a classa) False p119b) True

39) Which method(s) can we use to find if the returned value of getModifiers method represesents public and final at the same timea) isPublic()b) isFinal()c) isPublicFinal()d) A and B p143

40) Which following classes does java.lang.reflect.AccesibleObject is superclass of?a) Fieldb) Classc) Constructor p122d) Method

41) Through the Field Class its possible to…a) Find values of fieldsb) Find or modify the values of fields p126c) Modify the values of fieldsd) None of the above