Blog about Programming Languages & Coding

Blog about Programming Languages & Coding
Contents for Computer Science, IT, B.Sc. CS & IT, M.Sc. CS & IT, MCA, BE CS & IT, ME CS & IT , Interview Questions, Books and Online Course Recommendations from Udemy, Coursera, etc

ADVANCED JAVA MCQs

 ADVANCED JAVA MCQs


1.Which of these packages contains all the classes and methods required for even handling in Java?

a.               java.applet

b.               java.awt

c.               java.event

d.              java.awt.event


Answer: c

2.Which of these methods are used to register a keyboard event listener?

a.               KeyListener()

b.               addKistener()

c.                addKeyListener()

d.               eventKeyboardListener()


Answer: c


3. Which of these class is super class of all the events?

a.               EventObject

b.               EventClass

c.               ActionEvent

d.               ItemEvent


Answer: a


4. Which of these events will be notified if scroll bar is manipulated?

a.               ActionEvent

b.              ComponentEvent

c.              AdjustmentEvent

d.              WindowEvent


Answer:c


5.  In Graphics class which method is used to draws a rectangle with the specified width and height?

a. public void drawRect(int x, int y, int width, int height)
b. public abstract void fillRect(int x, int y, int width, int height)
c. public abstract void drawLine(int x1, int y1, int x2, int y2)
d. public abstract void drawOval(int x, int y, int width, int height

Answer: a

6.               Swing  is a part of _________________.

A.              Java Foundation Classes

B.               Java Function Classes

C.               Java defined  Classes

D.              Java object Classes

Answer: A

7.               _____________ is a simple component for displaying text, images or both.

a.               JLabel

b.               JButton

c.                JComboBox

d.               JTextArea

Answer: A

8.               _______________is a JTextField subclass that does not show the characters that the user types.

A.              JPasswordField 

B.               JLabelField 

C.               JButtonField 

D.              JRadioButton 

Answer: A


9.   The _______________ class is used to provide standard dialog boxes such as message dialog box, confirm dialog box and input dialog box. 

A.JOptionPane

B.JButton

C.JFrame

D.JMenu

Answer:A


10.The ___________________ class is used to display menubar on the window or frame.

A.JOptionPane

B.JButton

C.JFrame

D.JMenu

Answer: D


11. The ____________class is used to switch between a group of components by clicking on a tab with a given title or icon.

A.JTabbedPane 

B.A.JOptionPane

C.JButton

D.JFrame

Answer:A

 

 12. Which of the following are interface?

       1. ServletContext    2. Servlet    3. GenericServlet    4. HttpServlet

A.   1,2,3,4

B.   1,2

C.   1,3,4

D.   1,4

Answer: D

13. Through which tag you can define servlet context  in weB.  xml?

A.              config-param

B.               context-param

C.               init-param

D.              config-init-param

E.               Answer:B

 

14. Which of these classes define the getWriter() method that returns an object of type PrintWriter ?

A. HttpServletRequest

B.HttpServletResponse

C. ServletConfig

D.ServletContext

     

  Answer: B

 

15. When the Web Container initializes a servlet, it creates a _________ object for the servlet ?

A.   ServletConfig

B.   ServletInit

C.   ServletContext

D.   ServletDestroy

Answer: A

16. What are the two main types of servlet ?

A) General Servlet and HTTP Servlet

B) Generic Servlet and HTML Servlet

C) Generic Servlet and HTTP Servlet

D) Gender Servlet and SMTP Servlet      

Answer: B

17. All information send from web client is available in __________ object .

A) ServletRequest 

B) ServletResponse

C)  ServletOutputStream

D) ServletContext

Answer: A

 

18.         The connection interface has the following parameters:

A.  Port number

B.  URL, username, password

C.  Localhost 

D.  Forname

Answer: B

19. The steps to connect a database are 

A.   Select Driver, execute command, Connect 

B.   Connect, select driver, execute command , create DB 

C.   Execute only 

D.   Select Driver , Create DB, Connect,execute command

Answer: D


20.         Full form od JDBC_____________

A.              Java database connectivity

B.               Java down connectivity

C.               Java database combine

D.              Join database connectivity

Answer: A

 

21. When a container loads a JSP it invokes which method before servicing any requests?

A.  init() method.  

B.   initialization() method.  

C.   jspInit() method.  

D.   initial() method.  

   Answer: C

22. Which of the following do not supports JSP directly?

A.  Weblogic Server

B.  WebSphere Server

C.  Tomcat Server

D.  Apache HTTP Server

Answer: D

 

23. Which two types of text is included in JSP page?

A.  Static data and Dynamic data. 

B.   Static data and JSP Elements.

C.   Dynamic data and JSP Elements.

D.   Dynamic Data and Scriptlets.

  Answer: B

24. Which of the following is not a jsp directive?

A.  include  

B.   page  

C.   scriptlet  

D.   useBean

Answer: D

25. Which of the following are the valid scopes in JSP?

A.  request, page, session, application

B.  request, page, session, global

C. response, page, session, application

D. request, page, context, application

Answer: C

 26.     26. What is the need of a tag library?
A.  JSP tag libraries are used by Web application designers who can focus on presentation and the database access.

          B.   JSP tag libraries are used by Web application designers who can focus on presentation and other enterprise services.

          C.   JSP tag libraries are used by Web application designers who can focus on presentation

          D.   JSP tag libraries are used by Web application designers who can focus on access data from database.

Answer: C

 

27. Which tag is used to execute java source code in JSP?

A.  Scripting Elements 

B.   Directive Elements

C.   Standard Action Elements

D.   Declaration Elements       

 

Answer: A


28. Enterprise Bean Architecture consists of-

a.               Enterprise Bean Server, Enterprise Bean, Enterprise Bean Clients, and Other services like JNDI and JTS

b.               Enterprise Bean Server, Enterprise Bean Containers, Enterprise Bean, Enterprise Bean Clients

c.                Enterprise Bean Server, Enterprise Bean Containers, Enterprise Bean, Enterprise Bean Clients, and Other services like JNDI and JTS

d.               Enterprise Bean Server, Enterprise Bean, Enterprise Bean Clients, and Other services like JNDI and JTS

Answer: C 

 

29. EJB Architecture defines __           types of Enterprise Beans.

a.               4

b.               2

c.                3

d.               5

Answer: B

30. Which annotation is used to obtain reference to No-interface view or an enterprise bean through dependency injection?

a.               @Local

b.               @EJB

c.                @Remote

d.               @Jsp

 

Answer: B

31. WAR modules that contain enterprise module require an _____________deployment descriptor.

a.               ejb-jar.xml 

b.               web-jar.xml

c.                ejb.xml 

d.               sql-jar.xml 

Answer:A 

32. The container invokes the _____    _ methods on newly constructed bean instances after completion of all dependency injection and before first business method is invoked on the enterprise bean.

a.               @PostConstruct

b.               @PreDestroy

c.                @PreActivate

d.               @PostPassivate

Answer: A

 

 33. Which statement is correct?

A.  public interface EnterpriseBean extends Serializable { }

B.   public interface EnterpriseBean extends Remote{ }

C.   public interface EnterpriseBean extends EJB{ }

D.   public interface EnetrpriseBean extens Servlet{}

Answer: B

 

34. __________ Message is root interface of all JMS messages.

A. MessageListener 

B. MessageDrivenContext 

C. Message 

d. MessageDrivenBean

Answer: D

 

35. What is ORM.

A. Object Relation Map

B.  Object Rate Mapping

C.  Object Relational Mapping

D.  Object Relational Mapper

Answer: C

 

36.Which tool provides a set of persistent annotations to define mapping metadata. 

A.  JPA
B.   EJB
C.   XML
D.   JRE

Answer: A

 

37. Which of the following simplifies Object Relational Mapping tool.

A. Data Creation ,Data Isolation, Data Access

B.  Data Manipulation, Data Creation, Data Extraction

C.  Data Creation, Data Manipulation, Data Access

D.  Data Isolation, Data Extraction, Data Manipulation

 

Answer: C

38. What is the JPA equivalent of hibernate.cfg.xml file.

A.  configuration.xml

B.   persistence.xml

C.   jpA. configuration.xml

D.  jpA. persistence.xml

Answer: B

39. Which tool automatically creates the required SQL queries

A.  XML 

B.   JPQL

C.   ORM

D.   JPA

Answer: C

40. Which one is the simple java class that represents a row in a database table.

A.  Attribute

B.   Primary key  

C.   foreign key

D.   Entity

Answer: D

41. Which annotation is used to link two tables through a relation table? 

A.              @RelationTable

B.               @JoinTable

C.               @LinkTable 

D.              @GroupTable

 Answer: B

42. Which method is used to remove a persistent instance from the datastore.

A. Session.remove()

B. Session.delete()

C. Session.del()

E.    Session.rm()

 

43 JPA uses ________to create connection and setup the required environment.

A.              Persistence.java

B.               Persistence.txt

C.               Persistence.xml

D.              Persistence.db

 

44. _________ is a factory of JDBC connections.

a.               SessionFactory

b.               ConnectionProvider

c.                Transaction

d.               Session


45.  A __________ is used to get a physical connection with a database. 

a.               SessionFactory

b.               Session

c.                Transaction

d.               ConnectionProvider

 

1

The Java EE platform is designed to help developers to create                      .

(a)    Large scale applications

(b)    Multi-tired applications

(c)    C.Scalable and reliable applications

(d)    All of the above

2

                          is not a feature of Enterprise Application.

(a)    Powerful

(b)    B.Secure

(c)    Not reliable

(d)    Complex

3

Enterprise applications are useful for                                     .

(a)    Large Corporations

(b)    Small Corporations

(c)    Government Agencies

(d)    All of the above

4

Enterprise architecture is divided into                            tiers.

(a)    2

(b)    4

(c)    6

(d)    8

5

                           is not a Web Application Technology.

(a)    Java Servlet

(b)    Java Server Pages

(c)    Java Server Faces

(d)    Enterprise Java Bean

6

                         is not a Enterprise Application Technology.

(a)    Java Persistence API

(b)    Java Message Service API

(c)    Java Servlet

(d)    Enterprise Java Bean

7

                     is a Web Services Technology.

(a)    JAX-RS

(b)    EJB

(c)    JSP

(d)    JSF


8

Glassfish is a                                server.

(a)    Web

(b)    Application

(c)    Both A and B

(d)    None of the above

9

Java EE, the Java Enterprise Edition, is                            .

 

(a)    an improved version of the Java Standard Edition for business professionals.

 

(b)    a development environment, designed for creating enterprise applications.

 

(c)    a platform for enterprise class level, distributed application.

 

(d)    a replacement of the Java Virtual Machine for running internet applications.

10

Container services are configured via                          .

(a)   special configuration methods in Java Access Beans

(b)   deployment descriptors and/or annotations

(c)   resource property files

(d)   application server administration configuration

11

Which of the following is NOT true?

(a)  Java EE applications are based on 4 phases: development, assembly, deployment, administration.

(b)  Java EE applications are autonomic self-managing, self-healing, self- protecting enterprise applications.

(c)  Java EE applications are split up in multiple tiers: client tier, web tier, EJB tier and integration tier.

(d)  Java EE applications are typically a combination of application clients, web components and business components.

12

Which elements is not part of the Java EE specification?

(a)   Java FX

(b)   Java Mail

(c)     JTA

(d)   Unified Expression Language


13

Java EE profiles                               

(a)   are used for static monitoring of applications.

(b)   control directly the execution of Enterprise Java Beans.

(c)  are configurations of the Java EE platform, targeted at a specific class of applications,

(d)   provide additional security features for Java EE applications.

 

14

 

The best way to access a database from a standard Java EE application is           

(a)  based on a dynamic lookup of a datasource via JPA (Java Persistence Architecture).

(b)   using a JDBC DriverManager to optimize the connection to the database.

(c)   working with static SQL statements via SQLJ.

(d)   developing a customised persistency framework, based on JDBC type 1 drivers.

 

15

 

Which quote illustrates best the support of web services in Java EE: -

(a)  Java EE application servers contain a specific web services container to interact with other web services.

(b)  Java EE provides the required APIs and tools in order to quickly and effectively design, develop, test and deploy web services.

(c)  The web services support is part of the Java SE, and as such is available in Java EE too.

(d)   The Java EE server provides special deployment descriptors for web services.

 

16

 

The use of a relational database in a Java EE environment is supported best by             .

(a)   Bean Managed Persistent Enterprise Entity Beans.

(b)  POJO Entities with annotations and controlled by an implementation of the Java Persistence Architecture.

(c)   Container Managed transactional beans with direct JDBC access.

(d)   POJO beans and the specification of SQL in the EJB deployment descriptor.


17

Security in Java EE                                       .

(a)   is provided by the Java EE containers.

(b)  requires the Java Authentication and Authorisation Service (JAAS) on the web tier. (c)is implemented as single sign-on feature, relying on an LDAP server.

(d)is based on realms, users, groups and roles.

18

Which pattern is NOT defined as a Java EE pattern (or Java EE blueprint)

(a)   Business Delegate

(b)   Proxy

(c)   Service to Worker

(d)   Service façade

19

What are the functions of Servlet containers?

(a)    Lifecycle management

(b)    Communication support

(c)    Multithreading support

(d)    All of the above

 

20

 

Which of the following are interface?

1. ServletContext 2. Servlet 3. GenericServlet 4. HttpServlet (a) 1,2,3,4

(b) 1,2 (c) 1,3,4

(d) 1,4

21

The life cycle of a servlet is managed by

(a)    servlet context

(b)    servlet container

(c)    the supporting protocol (such as http or https)

(d)    All of the above


22

In which folder we can put web.xml?

(a)    class

(b)    package

(c)    WEB-INF

(d)    Webapps

 

23

 

Where we can put jar file?

(a)    classes

(b)    library

(c)    lib

(d)    WEB-INF

 

24

 

 Which life-cycle method make reddy the servlet for garbage collection?

       (a)    init

(b)    service

(c)    system.gc

(d)    destroy


25

 Through which tag you can define servlet context in web.xml?

       (a)    config-param

(b)    context-param

(c)    init-param

(d)    All of these

 

26

 

Which of the following method can be used to get the multiple values of a parameter like checkbox data?

(a)    request.getParameter()

(b)      request.getParameterValues()

(c)      request.getParameterNames()

(d)      None of the above.


27

When the Web Container initializes a servlet, it creates a                        object for the servlet?

(a)    ServletConfig

(b)   ServletInit

(c)    ServletContext

(d)   None of the above

 

28

 

Which of these classes define the getWriter() method that returns an object of type PrintWriter ? Select the one correct answer. ?

         (a)    HttpServletRequest

(b)   HttpServletResponse

(c)    ServletConfig

(d)   ServletContext

29

 

Which method defined in the HttpServletResponse may be used to set the content type

                 a)    setType()

(b)   setContent()

(c)    setContentType()

(d)   setResponseContentType()

 

30

 

When the Web Container initializes a servlet, it creates a                        object for the servlet ?

         (a)    ServletConfig

(b)   ServletInit

(c)    ServletContext

(d)   None of the above

31

What are the two main types of servlet ?

(a)    General Servlet and HTTP Servlet

(b)    Generic Servlet and HTML Servlet

(c)    Generic Servlet and HTTP Servlet

(d)    Gender Servlet and SMTP Servlet


32

Which is not life cycle method of Servlet ?

(a)    service ( )

(b)    delete ( )

(c)    init ( )

(d)    doPost ( )

33

Which protocol is used to interact with Web Client by Servlet?

(a)    HTTP

(b)    FTP

(c)    HLTP

(d)    SMTP

 

34

 

                     interface helps container to initialize Servlet .

(a)    ServletContext interface

(b)    Servlet interface

(c)    ServletConfig interface

(d)    All of above

 

35

 

All information send from web client is available in                      object .

(a)    ServletRequest

(b)    ServletResponse

(c)    ServletOutputStream

(d)    ServletContext

36

With which method of PrintWriter we can send character data in response ?

(a)    println()

(b)    getWriter()

(c)    out ()

(d)    All of above

37

--------------- method helps to sends request from servlet to another resource.

(a)    response ( )

(b)    print ( )

(c)    include ( )

(d)    forward ( )


38

Which methods are defined in HttpServletClass ?

(a)    service ( )

(b)    doGet ( )

(c)    doHead ( )

(d)    All of above

 

39

 

Is Cookie name and value is sent by Servlet to web browser ?

(a) Yes (b) No

(c) Can’t say

 

40

 

Which JDBC driver Type(s) can be used in either applet or servlet code?

(a)    Both Type 1 and Type 2

(b)    Both Type 1 and Type 3

(c)    Both Type 3 and Type 4

(d)    Type 4 only

41

The........................................... method executes a simple query and returns a single

Result Set object

(a)    executeUpdate()

(b)    executeQuery()

(c)    execute()

(d)    noexecute()

 

42

 

In which of the following type of ResultSet, the cursor can scroll forwards and backwards, and the result set is not sensitive to changes made by others to the database that occur after the result set was created.?

(a)      ResultSet.TYPE_FORWARD_ONLY

(b)      ResultSet.TYPE_SCROLL_INSENSITIVE

(c)      ResultSet.TYPE_SCROLL_SENSITIVE

(d)    None of the above.

43

Which of the following type of JDBC driver is the fastest one?

(a)      Type 1

(b)      Type 2

(c)      Type 3

(d)      Type 4


44

Which of the following is used to call stored procedure?

(a)    Statement

(b)    PreparedStatement

(c)    CallableStatment

(d)    CalledStatement

 

45

 

Which of the following is used to limit the number of rows returned?

(a)    setMaxRows(int i)

(b)    setMinRows(int i)

(c)    getMaxrows(int i)

(d)    getMinRows(int i)

 

46

 

Which of the following is advantage of using JDBC connection pool?

(a)    Slow performance

(b)    Using more memory

(c)    Using less memory

(d)    Better performance

 

47

 

What is a DataSource in terms of JDBC.

(a)    A DataSource is the basic service for managing a set of JDBC drivers

(b)    A DataSource is the Java representation of a physical data source

(c)    A DataSource is a registry point for JNDI-services

(d)    A DataSource is a factory of connections to a physical data source

 

48

 

Which method is used to perform DML statements in JDBC?

(a)    execute()

(b)    executeQuery()

(c)    executeUpdate()

(d)    executeResult()

49

How can you execute a stored procedure in the database?

(a)    Call method execute() on a CallableStatement object

(b)    Call method executeProcedure() on a Statement object

(c)    Call method execute() on a StoredProcedure object

(d)    Call method run() on a ProcedureCommand object


50

Which method is used to send the same request and response objects to another servlet in RequestDispacher ?

(a)      forward()

(b)      sendRedirect()

(c)      Both a and b

(d)      None of the above

 

51

 

Which object is used to forward the request processing from one servlet to another?

(a)    ServeltContext

(b)    ServeltConfig

(c)    RequestDispatcher

(d)    ResponceRedirect

 

52

 

What are methods of request dispatcher?

(a)    Include()

(b)    forward()

(c)    Include() and forward()

(d)    None of the above

 

53

 

                 method returns an object of RequestDispatcher

(a)    getRequestDispatcher(String path)

(b)    getNamedDispatcher(String name)

(c)    both a and b

(d)    None of the above

54

Request dispatcher interface is defined injavax.servlet package.

(a)    true

(b)    false

55

Which method is used to send response of one Servlet into another

(a)    forward

(b)    include

(c)    both a and b

(d)    None of the above


56

Which method is used to send client request to another sevlet but response to client given by another Servlet

(a)    include

(b)    forward

(c)      both a and b

(d)      None of the above

 

57

 

               object contains request of client and transfer control to another web components.

(a)    Cookies

(b)    b)include

(c)    Request dispatcher

(d)    d)forward

 

58

 

Which cookie it is valid for single session only and it is removed each time when the user closes the browser?

(a)    Persistent cookie

(b)    Non-persistent cookie

(c)    All the above

(d)    None of the above

 

59

 

Cookies make it easy for web servers to personalize information to fit specific needs and preferences when you visit a website.

(a)    True

(b)    False

 

60

 

Cookies may also called as HTTP cookies or web cookie or internet cooki

(a)    True

(b)    False

 

61

 

Persistent cookie does disapper after user exists a site.

(a)    True

(b)    False


62

Which package is provided by Servlet API to work with cookies.

(a)    javax.servlet

(b)    javax.servletrequest

(c)    javax.servletresponse

(d)    javax.servlet.http.Cookie

 

63

 

Where are cookies placed in computer?

(a)    Browser

(b)    Drive

(c)    List

(d)    Folder

 

64

 

Session ids are stored in cookies?

(a)    True

(b)    False

(c)    May be

(d)    can't say

 

65

 

What is the maximum size of cookie?

(a)    4 bytes

(b)    4 mb

(c)    4 kb

(d)    40mb

 

66

 

which attribute is used to extend the lifetime of a cookie?

(a)    Name

(b)    MaxAge

(c)    Path

(d)    Value

 

67

 

Syntax for creating a cookie

(a)    Cookies ck= new cookies(“ name" , “ value”);

(b)    cookie ck = new cookies(“ name”);

(c)    cookie ck= new cookie(“ name”);

(d)    Cookie ck = new Cookie(“ name”, “ value”):


68

If you set the expiration time to        then cookie will be removed from browser.

(a)    1

(b)    -1

(c)      0

(d)    2

 

69

 

How can you set cookie visibility scope to local storage?

(a)    %

(b)    *

(c) +

(d) /

 

70

 

Cookie manipulation is done by using which property

(a)    Cookie

(b)    Cookies

(c)    Manipulate

(d)      None of the above

 

71

 

                    does not wait for the data to be read or write before returning.

 

(a)   Non blocking IO

(b)   Servlet

(c)   Cookie

(d)   Session

72

Non blocking IO is                             oriented

 

(a)    bit

(b)    Stream

(c)    Buffer

(d)    Byte

73

                  are available for Non-blocking I/O operation

 

(a)   Channels

(b)   Selectors

(c)   Threads

(d)   Both a & b


74

A stream can be used for                           data transfer.

(a)    Two way

(b)    One way

(c)    No way

(d)    continuous

 

75

 

A channel provides a                 data transfer facility.

(a)    Two way

(b)    One way

(c)    No way

(d)    continuous

76

A ServletInputStream Interface consist of                 methods

(a)    2

(b)    3

(c)    4

(d)    5

77

onDataAvailable () and onAllDataRead methods are consist of                    

 

(a)    ReadListener

(b)    WriteListener

(c)    Servlet

(d)    JSP

78

onWritePossible() method is consist of                     

 

(a)    ReadListener

(b)    WriteListener

(c)    Servlet

(d)    Listener

79

MultipartConfig annotation has                              attributes

 

(a)    Location

(b)    maxFileSize

(c)    maxRequestSize

(d)    all of the above

80

WriteListener is used to                         the data

 

(a)    asynchronize

(b)    synchronize

(c)    buffer

(d)    upload


81

Which of the following code is used to get an attribute in a HTTP Session object in servlets?

(a)      session.getAttribute(String name)

(b)      session.alterAttribute(String name)

(c)    session.updateAttribute(String name)

(d)      session.setAttribute(String name)

 

82

 

Which method is used to specify before any lines that uses the PrintWriter?

(a)    setPageType()

(b)      setContextType()

(c)    setContentType()

(d)    setResponseType()

 

83

 

Which object of HttpSession can be used to view and manipulate information about a session?

(a)      session identifier

(b)    creation time

(c)    last accessed time

(d)    All of the above

 

84

 

Which of the following code is used to get session id of a HTTP Session object in servlets?

(a)    session.getSessionId()

(b)    session.getId()

(c)    session.getActiveId()

(d)    None of the above.


 

 


85

Which page directive should be used in JSP to generate a PDF page?

(a)    contentType

(b)    generatePdf

(c)    typePDF

(d)    contentPDF

 

86

 

Which of the following do not supports JSP directly?

(a)    Weblogic Server

(b)    WebSphere Server

(c)    Tomcat Server

(d)    Apache HTTP Server

 

87

 

Which attribute specifies a JSP page that should process any exceptions thrown but not caught in the current page?

(a)    The ErrorPage Attribute

(b)    The IsErrorPage Attribute

(c)    Both A & B

(d)    None of the above

 

88

 

How many jsp implicit objects are there and these objects are created by the web container that are available to all the jsp pages?

(a)    8

(b)    9

(c)    10

(d)    7

 

89

 

Which of the following are the valid scopes in JSP?

(a)    request, page, session, application

(b)    request, page, session, global

(c)    response, page, session, application

(d)    request, page, context, application


90

Which of the following is not a jsp directive?

(a)    include

(b)    page

(c)    scriptlet

(d)    useBean

91

Which of the following is true about Cleanup phase in JSP life cycle?

(a)    The destruction phase of the JSP life cycle represents when a JSP is being removed from use by a container.

(b)   The jspDestroy() method is the JSP equivalent of the destroy method for servlets.

(c)    Both of the above.

(d)    None of the above.

92

Which one is the correct order of phases in JSP life cycle?

(a)    Initialization, Cleanup, Compilation, Execution

(b)    Initialization, Compilation, Cleanup, Execution

(c)    Compilation, Initialization, Execution, Cleanup

(d)    Cleanup, Compilation, Initialization, Execution

93

Which tag should be used to pass information from JSP to included JSP?

(a)    using <%jsp:page> tag

(b)    using <%jsp:param> tag

(c)    using <%jsp:import> tag

(d)    using <%jsp:useBean> tag

94

 

JSTL catch tag is used to handle exception and forward the page to the error page.

(a)    True

(b)    False

95

 

What will be output of the JSP code?

${101 % 10}

 

(a)    1

 

(b)    10

(c) 101

 

(d) 0


96

Which tag is used to execute java source code in JSP?

(a)    Scripting Elements

(b)    Directive Elements

(c)    Standard Action Elements

(d)    All of the above.

97

What is the syntax of scriplet tag? (a)  <%--------------- %>

(b)  <%                  %> (c)  <%=            %>

(d)  <%!             %>

98

What is difference between <%-- comment --%> and <!-- comment -->?

(a)    <%-- comment --%> is JSP comment. <!-- comment --> is an HTML comment.

(b)    <%-- comment --%> is ignored by JSP container.

(c)    <!-- comment --> is ignored by browser.

(d)    All of the above.

99

A JSP page consists of which tags?

(a)    HTML tags.

(b)    JSP tags.

(c)    Both (a) and (b).

(d)    None of the above.

100

Which tag is used to declare variables as well as methods?

(a)    JSP Scripting

(b)    JSP Directive

(c)    JSP Standard Action

(d)    JSP Declaration

101

Which is not a directive?

(a)    Include

(b)      Page

(c)    Export

(d)    Taglib

102

Which attribute defines the MIME type of the HTTP response?

 

(a)    ContentType

(b)    language

(c)    PageEncoding

(d)    isELIgnored


103

What is the use of errorPage Attribute in JSP Page directive?

(a)    Is used to declare that the current page is the error page.

(b)   If exception occurs in the current page, it will be redirected to the error page.

(c)    Both (a) and (b) are true.

(d)    Neither (a) nor (b).

104

How can one JSP Communicate with Java file?

(a)  <%@ page extends=”.... ” %>

(b) <%@ page import=”.....” %> (c) <%@ page info=”.....” %>

(d) <%@ page isELIgnored=".... " %>

 

105

 

What is the need of a tag library?

 

(a)    JSP tag libraries are used by Web application designers who can focus on presentation

(b)      JSP tag libraries are used by Web application designers who can focus on presentation and the database access.

(c)    JSP tag libraries are used by Web application designers who can focus on presentation and other enterprise services.

(d)   All of above.

 

106

 

What is the full form of JSTL

(a)    JSP tag library

(b)    Java server pages tag library

(c)    Java Standard Tag library

(d)    None of the above

 

107

 

A JSP file uses a tag as <myTaglib:myTag> The myTag element here should be defined in the tag library descriptor file in the tag element using which element.Select the one correct answer.

(a)    tagname

(b)    name

(c)    tag

(d)    prefix                                                                          


108

Which of the type of Java conditional statement is the <c:choose> tag similar to? (a) if

(b)    switch

(c)    when

(d)    for

 

109

 

What is the default value of the type attribute for the <fmt:formatNumber> and

<fmt:parseNumber> actions?

(a)    Currency

(b)    Percentage

(c)    number

(d)    dollar

 

110

 

Prefix of function tag library begins with?

(a) func (b) f

(c) fun (d) fn

 

111

 

How to query and update in database transaction in JSTL?

(a)    <Sql:transact>

(b)    <Sql:query>

(c)    <sql:update>

(d)    <sql:transaction>

 

112

 

Which JSTL provide supports for string manipulation?

(a)    JSTL String

(b)    JSTL function

(c)    JSTL XML

(d)    JSTL formatting


113

Which Custom tag is used to dynamically add the contents from the provided URL to the current page at request time?

(a)    <c:import>

(b)    <c:include>

(c)    <c:content>

(d)      None of the above


 

 


114

Enterprise Bean Architecture consists of-

(a)    Enterprise Bean Server, Enterprise Bean, Enterprise Bean Clients, and Other services like JNDI and JTS

(b)    Enterprise Bean Server, Enterprise Bean Containers, Enterprise Bean,

Enterprise Bean Clients

(c)    Enterprise Bean Server, Enterprise Bean Containers, Enterprise Bean,

Enterprise Bean Clients, and Other services like JNDI and JTS

(d)   Enterprise Bean Server, Enterprise Bean, Enterprise Bean Clients, and Other services like JNDI and JTS

115

An EJB Server takes care of-

(a)    Security

(b)    Threads

(c)    Connection Pooling

(d)    All of the above

 

116

 

Business Components developed using EJB Architecture are called as-

(a)    Java Beans

(b)    Enterprise Java Beans Components

(c)    Enterprise Modules

(d)   None of the Above (e)

117

                   is responsible for managing the active state for object, for each enterprise bean.

(a)    Container

(b)    Server

(c)    Client

(d)    JNDI

118

               bean can implement web service, but other types of Enterprise Beans cannot.

(a)    Stateful

(b)    Singleton

(c)    MessageDriven


119

Only a single client can use                       session bean at a time.

(a)    Stateful

(b)    Singleton

(c)    MessageDriven

(d)    Stateless

 

120

 

                         session beans are instantiated once per application and exist for the lifecycle of the application.

(a)    Stateful

(b)    Singleton

(c)    MessageDriven

(d)    Stateless

 

121

 

Session Beans can be accessed from –

(a)    Remote Java clients

(b)    Web service clients

(c)    Components running in same server

(d)    All of the above

122

Which annotation is used to obtain reference to No-interface view or an enterprise bean through dependency injection?

(a)    @Local

(b)    @EJB

(c)    @Remote

(d)    Any of above

123

Stateful session passes through      stages during its lifetime.

(a)    4

(b)    1

(c)    2

(d)    3

124

Which is the method for Message Driven Beans?

(a)    onmessage()

(b)    onMessage()

(c)    Meassage()

(d)    getMessage()


125

Which of the following is true for Java Bean?

 

(a)    It can not be a GUI component

(b)      It never implements serializable interface

(c)    It has zero-argument constructor

(d)    It is a distributed component

126

Which EJB container must provide an implementation of Java Naming and Directory Interface (JNDI) API to provide naming services for EJB clients and components?

 

(a)    Transaction support

(b)    Persistence support

(c)    Naming support

(d)    Session support

127

What represents a persistent global data from the database?

(a)    Entity Bean

(b)    Session Bean

(c)    Both A & B

(d)    Only A

128

Which type of instances retain no data or conversational state for a specific client?

(a)    Message-Driven Bean

(b)    Session Bean

(c)    Entity Bean

(d)    Persistant Bean

 

129

 

What is JNDI?

(a)    Java Naming Directory Instance

(b)      JDBC Naming Directory Interface

(c)    Java Naming and directory interface

(d)    Java Naming and data interface

130

Which of the following is correct about @PreUpdate annotation for an entity bean?

 

 

(a)    Method is invoked before an entity is to be updated in the database

(b)   Method is invoked after an entity is created in database

(c)    Method is invoked when an entity is deleted from the database

(d)   Method is invoked after an entity is deleted from the database


131

Which of the following annotation is used to specify or inject a dependency as ejb instance into another ejb?

(a)    @javax.ejb.Stateless

(b)    @javax.ejb.Stateful

(c)    @javax.ejb.MessageDrivenBean

(d)    @javax.ejb.EJB

 

132

 

Which role in EJB architecture is responsible for EJB Server? (a)EJB Deployer

(b)Application Assembler (c)Network Engineer (d)Server Provider

 

133

 

Which statement is correct?

 

(a)    public interface EnterpriseBean extends Serializable { }

(b)    public interface EnterpriseBean extends Remote{ }

(c)    public interface EnterpriseBean extends EJB{ }

(d)    public interface EnetrpriseBeanextensServlet{}

 

134

 

Which is not the reuirementofAroundInvoke method in interceptor?

(a)    OneAroundInvoke method is allowed for each class.

(b)      It must have a no argument public constructor.

(c)    It must accept a javax.interceptor.InvocationContext object as an argument and return a java.lang.Object object.

(d)    It will call serializable method

135

The association of a name with an object is called a               .

(a)    Binding

(b)    Context

(c)    Convention

(d)    Association


136

               acts as an abstract layer between user and shared resources on a network.

(a)    Software Application

(b)    Directory Services

(c)    Network addresses

(d)    Directory Interfaces

 

137

 

Which among these are JNDI namespaces used for JAVA Lookups.

(a)    java: context

(b)    java: global

(c)      both

(d)      none


 

138

Which one of the following best illustrates the concept of Object Persistence.

(a)    Determining how an object’s state[data stored in member variable of an object ] is stored in database table columns.

(b)    Provides an object – oriented view of persistent data.

(c)    Design patterns and sophisticated object oriented concepts such as inheritance and polymorphism can be used.

(d)    Provide one to one mapping to database table.

139

Which of the following is not a correct explanation of JDO.

(a)    JDO is a standard way to access persistent data in databases, using plain old Java objects (POJO) to represent persistent data.

(b)    JDO is an object relational mapping tool.

(c)    Provides object relational query language and support non-relational databases.

(d)    JDO was popular and an integrated part of enterprise java platform.

 

140

 

What is ORM.

(a)    Object Relation Map

(b)    Object Rate Mapping

(c)    Object Relational Mapping

(d)    Object Relational Mapper

141

Which method is used to remove a persistent instance from the datastore.

(a)    Session.remove()

(b)    Session.delete()

(c)    Session.del()

(d)    Session.rm()

142

Which tool provides a set of persistent annotations to define mapping metadata.

 

(a)    JPA

(b)      JSR

(c)      XML

(d)    JRE

143

Which of the following simplifies Object Relational Mapping tool.

(a)    Data Creation ,Data Isolation, Data Access

(b)    Data Manipulation, Data Creation, Data Extraction

(c)    Data Creation, Data Manipulation, Data Access

(d)    Data Isolation, Data Extraction, Data Manipulation


144

The problem which arises because of the difference between model of programming language and model of database is classified as.

(a)    modelling mismatch

(b)    referential mismatch

(c)    dependence mismatch

(d)    impedance mismatch

145

Which technique is used by Hibernate to persist collections of embeddable types.

(a)    ElementCollection

(b)    ManyToMany

(c)    OneToMany

(d)    CollectionElement

146

What is the JPA equivalent of hibernate.cfg.xml file.

(a)    configuration.xml

(b)    persistence.xml

(c)    jpa.configuration.xml

(d)    jpa.persistence.xml

147

To get the first application to work the                      needs to be setup.

(a)    Database

(b)    ORM tools of choice

(c)    Entity- Plain Old Java Objects (POJO)

(d)    All of the above.

148

Which of the following softwares is not required in development perspective?

(a)    Netbeans

(b)    MySQL database

(c)    Android studio

(d)    JDBC driver for MySQL

149

A typical JPA application will usually have                    

(a)    Single persistent unit

(b)    One entity manager factory

(c)    Both a. and b.

(d)    None of the above.

150

Mapping in hibernate can be given to an ORM tool either in the form of an             or in the form of the annotations

(a)   XHTML

(b)   JSON

(c)   HTML

(d)   XML

 

ADVANCED JAVA MCQs ADVANCED JAVA MCQs Reviewed by Asst. Prof. Sunita Rai, Computer Sci.. Dept., G.N. Khalsa College, Mumbai on January 11, 2022 Rating: 5

No comments:

Powered by Blogger.