You are on page 1of 8

1.

Int fn (int v)
{
If (v==1 || v==0)
Return 1;
If (v%2 == 0)
Return fn (v/2) + 2;
Else
Return fn (v-1) + 3;
}
For fn (7)

A. 11
B. 10
C. 12
D. 13

2. What is the output of the following code fragment?
{
x = 4
y = 3
If (x = y - x + 1)
Printf ("%d\n", x * 2)
Else
Printf (%d\n, x + y)
}

A. 3
B. 7
C. 8
D. 0

3.










4. After the declaration:
Typedef struct {
Int height;
Double weight;
Double wealth;
} dwarf

A. Dwarf is a new data type which, when used declares variables as pointers to a
record
B. Dwarf is a variable which holds a record
C. Dwarf is a variable which holds a pointer to a record
D. Dwarf is a new data type which, when used, declares variable as records

5. Given the following defintions:
Typedef struct {int a, b, c; char * x} record_type;
Record_type *p_rec;
Record_type rec;
A statement that dynamically allocates space for P_rec is

A. P_rec = (Rec*)malloc(sizeof Rec);
B. P_rec = (record_type)malloc(sizeof Rec);
C. *P_rec = malloc(sizeof(struct Rec));
D. P_rec = (record_type*)malloc(sizeof Rec);

6. The main differences between structures and arrays is:
A. Structs contain components of different types, but array components are of the
same type
B. There is no practical difference, structs and arrays may be used interchangeably
C. Structs may contain pointers, but arrays may not
D. Arrays are of fixed size, while structs may vary in size


7. What relationship is expressed by inheritance?
A. A mother and father relationship
B. A really cool one
C. An "is-a" relationship
D. A "has-a" relationship

8. Using multiple source files and separate compilation of modules allows the
programmer to
A. Reuse code
B. Reduce compilation time
C. Create function libraries
D. All of them

9. What is the effect of the following code?
This is too tricky. Should not use

Int I, x = 1;
For (i =1; i<=4; i++)
{
x *= 3;
printf(%d\n, x);
}
A. It prints out the numbers from 1 to 4
B. It prints out the powers of 3 between 3 and 81
C. It prints out the multiples of 3 between 3 and 12
D. It prints out the numbers from 1 to 3

10. You are writing a class, and you create a contractor that can take in int
parameter is addition is the default contractor
This is an example of what?

A. Function Aggregation
B. Function Junctice
C. Function Overriding
D. Function Overloading

11. What is Polymorphism?
A. The ability of a variable to participate in static binding
B. Refers to the overriding of functions
C. Refers to the overloading of functions
D. The ability of a variable to take on more than one form

12. The expression *p++ can be interpreted as:
A. Increment p, and then give the value of whatever p points to
B. Increment the value points to by p
C. The current value of what p points to, then, as a side effect, incerment p
D. The expression is not legal

13. Which of the give expressions is equivalent to the following expression for all
values of the integer variable i
(i != 2) && (i != 3)

A. S1 (i< 2) || (i> 3)
B. S2 (i<= 2) || (i >= 3)
C. S3 (i< 2) && (i> 3)
D. S4 (i<= 2) && (i>= 3)

14. The free function is used to
A. Release a file the program has completed using it
B. Release dynamically allocated memory and set the pointer to it to NULL
C. Cast a pointer of one type to a different type
D. Release dynamically allocated memory


15. What is template class/function useful?
A. They can replace many overloaded function with one function in certain
situations
B. All of them
C. They allow a programmer to write a single function/class definition for many
types
D. They allow a class/function to take on more than one form at compile-time

16.

17.

18.

19.

20.

21. What executes EJB components
A. An application server
B. An EJB container
C. A web server
D. A database server

22. Choose the statement that best describes the relationship between jsp and
servlets
A. JSP and servlets are unrelated technologies.
B. Servlets and JSP are competing technologies for handling web requests.
Servlets are being superseded by JSP, which is preferred. The two technologies
are not useful in combination.
C. Servlets are built on JSP semantics and all servlets are compiled to JSP pages
for runtimeusage.
D. JSPs are built on servlet semantics and all JSPs are compiled to servlets for
runtime usage.

23. The name of java virtual machine for J2ME CDC is
A. PersonalUsege
B. JVM
C. KVM
D. CVM

24. When using a JavaBean to get all the parameters from a form, what must the
property be set to (??? In the following code) for automatic initialization?
<jsp:useBean id="fBean" class="govi.FormBean" scope="request"/>
<jsp:setProperty name="fBean" property="???" />
<jsp:forward page="/servlet/JSP2Servlet" />
A. *
B. all
C. @
D. =

25. What is Polymorphism?
E. The ability of a variable to participate in static binding
F. Refers to the overriding of functions
G. Refers to the overloading of functions
H. The ability of a variable to take on more than one form

26. Which of the following will not cause a JDBC driver to be loaded and
registered with the DriverManager?
A. Class.forName (driverString);
B. New DriverClass ();
C. Include driver name in jdbc.drivers system property
D. None of them

27. What type of enterprise bean is used to embody application processing state
information?
A. javax.ejb.EnterpriseBean
B. javax.ejb.SeesionBean
C. javax.ejb.EmtityBean
D. javax.mi.Remote

28. Which of the following can you do with a JDBC 2.0 database driver that you
cannot with a JDBC 1.x driver?
A. Work with SQL3 data types directly
B. Batch multiple statements, to be sent to the database together
C. All of them
D. Scroll through result sets bi-directionally

29. Which character is used to represent an input parameter in a
CallableStatement?
A. %
B. *
C. ?
D. #

30. What is a benefit of using JavaBeans to separate business logic from
presentation markup within the JSP environment?
A. It provides the developer with full access to the Java 2 Platform Enterprise
Edition (J2EE), which is unavailable from outside the JavaBean environment.
B. It provides a dynamic markup environment, such that JavaBeans are integrated
seamlessly with the template presentation content, in order to create the
dynamic display for the client.
C. It creates a cleaner role separation between the web-production team and the
software development team, so that the web-production team can focus on
presentation markup, while the software team can focus on building reusable
software components for helping to generate dynamic displays .
D. It allows the JSP to access middleware.

31. What does the EJB specification architecture define?
A. Transactional components
B. Distributed object components
C. Server-side components
D. All of them

32. What type of scriptlet code is better-suited to being moved into a servlet?
A. Code that deals with logic that relates to client scope.
B. Code that deals with logic that is vendor specific.
C. Code that deals with logic that relates to database access.
D. Code that deals with logic that is common across requests.

33. How can I use JDBC to create a database?
A. Include create = true at end of JDBC URL
B. Database creation is DBMS specific
C. Execute "STRSQL" and "CREATE COLLECTION jGuru" SQL statements
D. Execute "CREATE DATABASE jGuru" SQL statement

34. Say you writing a class, and you create a contractor that can take in tow int
parameter in addition to the default contractor
This is an example of what?
A. Function Aggregation
B. Function Junctice
C. Function Overriding
D. Function Overloading

35.

36. From which object do you ask for DatabaseMetaData?
A. Connection
B. ResultSet
C. The DriverManager
D. Driver

37. Why use RequestDispatcher to forward a request to another resource, instead
of using a sendRedirect?
A. Redirects are no longer supported in the current servlet API.
B. Redirects are not a cross-platform portable mechanism.
C. The RequestDispatcher does not use the reflection API.
D. The RequestDispatcher does not require a round trip to the client, and thus is
more efficient and allows the server to maintain request state.

38. What type of enterprise bean is used to embody business objects?
A. javax.ejb.EnterpriseBean
B. javax.ejb.SeesionBean
C. javax.ejb.EmtityBean
D. javax.mi.Remote

39. Choose the statement that best describes how to content JSP pages and
Enterprise enterprise javabeans (EJBs)
A. Lookup and use the EJBs from within a JSP page, but only as remote
references
B. Lookup and use the EJBs from a separate business delegate. The JavaBeans the
work with JSP pages are clients to these business delegate
C. Lookup the EJBs from within a servlet, delegating usage to specific JSP pages
D. Lookup the EJBs from within a JSP, but use the EJBs from within a basic
JavaBean

40. What is the initial contact point for handling a web request in a Page-Centric
architecture?
A. A JSP page.
B. A JavaBean.
C. A servlet.
D. A session manager.

41. Why would you want a trigger to rollback the transaction that fired it?
A. To drop any temporary tables that were created
B. To prevent a nested trigger from firing
C. You wouldn't, and this is usually not allowed
D. To reverse a data modification action that failed colunm-leved validation

42. The SQL command to execute a trigger directly is
A. Update
B. None of them
C. Insert
D. Exec

43. In a database normalized to the third narmal form, non-primary key fields
A. Can hold multiple values within a single row
B. Are not related to primary key fields
C. Are independent of foreign key fields
D. Do not depend on the values of other non-key fields

44.

45. Which Select keywords are mandatory?
A. SELECT, FROM
B. SELECT, FROM, WHERE
C. none of them
D. SELECT, WHERE

46.

You might also like