- OBJECTIVE
QUESTIONS
JAVA INTERVIEW QUESTIONS AND ANSWERS PART 1
JAVA INTERVIEW QUESTIONS AND ANSWERS PART 2
JAVA INTERVIEW QUESTIONS AND ANSWERS PART 3
JAVA INTERVIEW QUESTIONS AND ANSWERS PART 4
JAVA INTERVIEW QUESTIONS AND ANSWERS PART 5- JAVA INTERVIEW QUESTIONS AND ANSWERS PART 6
JAVA INTERVIEW QUESTIONS AND ANSWERS PART 7
JAVA INTERVIEW QUESTIONS AND ANSWERS PART 8
JAVA INTERVIEW QUESTIONS AND ANSWERS PART 9
JAVA INTERVIEW QUESTIONS AND ANSWERS PART 10- RMI
- FILTER STREAM
- TCP
& UDP
JAVA CODE FOR TCP MESSAGE TRANSFER
JAVA CODE FOR TCP CHAT APPLICATION
JAVA CODE FOR TCP FILE TRANSFER
JAVA CODE FOR UDP DATAGRAM-TRANSFER- JDBC
- SESSION MANAGEMENT
JAVA CODE FOR SERVLET-URL
JAVA CODE FOR SERVLET-HIDDEN FIELD
JAVA CODE FOR COOKIES
JAVA CODE FOR SERVLET-SESSION IDS- JAVA CODE FOR CORBA
JAVA CODE FOR NODE STREAM- SERIALIZATION
- THREAD
JAVA CODE FOR INTERTHREAD COMMUNICATION
JAVA CODE FOR PRIORITY TRAIN BOOKING
JAVA CODE FOR SYNCHRONIZATION - JOIN- APPLICATIONS
Showing posts with label Java. Show all posts
Showing posts with label Java. Show all posts
Saturday, July 11, 2015
JAVA
Friday, May 23, 2014
Objective Java Multiple Choice Questions Part 10
91. If there are too many entities with the
EntityManager which of the following should be used?
a. EntityManager.clear()
b. EntityManager.delete()
c. EntityManager.discard()
d. EntityManager.save()
92. Purpose
of Service Locator pattern
à The Service Locator hides the lookup process's implementation details
and complexity from clients.
93. What exception is thrown by
EntityManager.find()?.
Returns null
IllegalStateException
IllegalArgumentException
94. What is the XML tag used to set max pool
size?
max-pool-size
95. Concept of MOM?
Ans: client---middleware---server
96. What semantics is used by application server to
call a remote interface? -
RMI
97. Which bean is used to manage interaction between
different entity beans?
Session Beans
98. Optimisation of SQL call is present in which EJB?
a. CMP
b. BMP
c. Stateful
d. Stateless
99. When
does Unrepeatable problem occur?
a. When
one transaction deletes a record and another reads it
b. When
one transaction reads a record and another updates it
c. None
100. Why entity beans are called transactional
resources? (Expln: Cos they access DB for storing data often)
a Cos
they’re used in transactions
Objective Java Multiple Choice Questions Part 9
81. JBoss server capable of hot deploy of services
keeping track of dependencies. T/F? –
82. Which is
a consumer in Topic?
MessageSubscriber
83. Which is a producer in Topic?
MessagePublisher
84. Which of the following is correct?
a. EntityManager
em=context.lookup();
b. EntityManager
em=context.lookup(“persistence”);
c. EntityManager
em=(EntityManager)context.lookup();
d. EntityManager
em=(EntityManager)context.lookup(“persistence”);
e.
EntityManager
em=(EntityManager)context.lookup(“java:comp/ejb/entitymanager”);
85. Why do we not have any activation or passivation
in MDB like in session beans?
as MDB
receives messages at any time asynchronously
86.Match annotation with purpose:
@EntityListener- Used for Entity beans call back
method.
@ExcludeSuperClassListener – In an inheritance
hierarchy, the super class listener is ignored in the subclass
@ExcludeDefaultListener – DefaultListener will be
ignored.
87. Which protocol is used for remote calls?
RMI-IIOP
88. Which declaration of local interface is correct?
There was only one option with @Local annotation.
89. If an object is not found during JNDI lookup
what exception is thrown?
NamingException
90. What has replaced entity beans?
a. Persitence API
b. Database API
Objective Java Multiple Choice Questions Part 8
71. Who is Consumer in Topic..?
Topic
Destruction.
Topic
subscriber
Topic
Messages.
Topic
publisher.
Topic
consumer.
72 @version
is used in beans that change less
frequently.
True
false
73. MDBs are
like ______
Stateless beans
74. A large
code regarding bean managed transaction (check for the comments)
The answer is the option “ut=sc.getTransaction(); //
to get transaction from sessioncontext”
75. MDBs used which of the annotations
a. Postconstruct
b. Predestroy
@Resource
@MessageDriven
76. Select one of the options dat best describes
Entity beans(so many options with large codes will be given)
The answer is
mostly “IT’S A POJO CLASS WITH ANNOTATIONS”
77. Diff between stateless and stateful bean:
Stateful can use return values of one method in
another but stateless cant do it
78. Which
is not a valid bean state?
a. Does
Not Exist
b. Ready
c. Pooled
d. No
State
79. Which is a client of a session bean implementing
local interface?
a. Session,entity
and MDB
b. Stateless
bean
c. Stateful
bean
d. Client
class must have a jndi lookup
e. mdb(could
be)
80. How to
convert an MDB from stateless to stateful.
a.
Cannot be done
Objective Java Multiple Choice Questions Part 7
61. @Entity
@Table
Public class entitybean {
}
What will the table name for this snippet?
Same as
the class name (i.e. entitybean)
Null
None
Entity
62. For which
option use of EJB not preferred
Fast
processiong
Transacion
processing
Security
maintenance
Content
presentation
63 . EJBHomeFactory pattern is used for
EJBHome
implementation dynamically
Satatic
home obj lookups
Catching
EJBHome Objects
Factory
of EJBHome obj catched for future ref
64. SELECT ac
FROM acct AS ac WHERE id in(1,2)
Selects
id at position 1
Selects
id at position 2
Selects
id at position 1 or postion 2
65. Default
value of @Entity
CMP
BMP
Entity
66. 17. Messages uses ___ protocol and RMI uses
____ protocol
TCP and
RMI-IIOP
TCP/IP
and RMI-IIOP
RMI and
TCP
RMI-IIOP
and TCP
67. How to limit flush to only after the execution
is complete
setFlushMode(FlushModeType.COMMIT)
setFlush(FlushModeType.COMMIT)
None
68. Methods
of a MDB interface
ejbCreate() and
setMessageDrivenContext()
ejbRemove() and
setMessageDrivenContext()
ejbactivate()
and setMessageDrivenContext()
ejbpassivate()
and setMessageDrivenContext()
69. What type
of bean can be used for records that are read and updated frequently
BMP
CMP
Stateful
Sateless
70. SELECT
NEW ejb.30.entity.CustomerRef(c.firstname,c.lastname,c.refreename) FROM C
Creates
a new CustomerRef object and puts the firstname lastname and refreename to it
Illegal
Null
Returns
a collection of CustomerRef, which contains first name, lastname and refreename
of all rows –
Objective Java Multiple Choice Questions Part 6
51. Remote
calls use (CB)
a. RMI/IIOP
b. TCP/IP
c. TCP
d. IIOP/RMI
e. RPC
52. EntityManager
reference can be obtained from inside or outside of EJB container
a. True
b. False
53. Which
of the following does not raise an exception when a method is not called from
within a txn
a. REQUIRED
b. REQUIRES_NEW
c. NEVER
d. SUPPORTS
e. NOT_SUPPORTED
54. EntityManager
can flush before query ends
a. True
b. False
55. Select
object(p) from Player p
When findAll method is implemented in
LocalPlayerHomeInterface the query returns objects of type
i. Player
ii. LocalPlayer
a. i
b. ii
c. i
& ii
56. Exception
that occur when there is no JNDI lookup match
BindingException
NamedDoesNotExsistExption
NullPointerException
DoesNotExsistNamedException
57. Property not annotated but serialized is mapped
to column using
@Embedded
@embeddable
@basic
@Serialized
58. Design pattern for Read only
FastReader
AbstractFactory
Fastline
Reader
Singleton
59. MessageListener class is
Has one
method
Is a
marked interface
Has
2 methods
60. Coarse grained EJB are
Fast
Slow
Difficult
to maintain
Serializable
Objective Java Multiple Choice Questions Part 5
41. Select
c.name , a.address from customer c left outer join address a
The above query will fetch
i. Customers
without address
ii. Customers
with address
Which are valid ?(d)
a. i
b. ii
c. both
d. none
42. In
publish / subscribe messaging (CB)
a. There
can be many receivers
b. The
receiver need not stay connected
43. Which
of the following are not generator types (CB)
a. TABLE
b. NULL
c. IDENTITY
d. ENTITY
e. none
44. Java
objects mapped to relational DB
a. ORM
b. JPA
c. Persistence
d. Entity
45. Which
method must be implemented in CMP
a. ejbCreate()
b. atleast
one ejbFindXXX()
46. MessageListener has
a. Has
only one method
b. Has
one method
c. Hes
two methods
d. Methods
can be added
e. Marker
interface
47. Which
of the following is valid declaration of remote interface
a. @Remote
b. remote
48. select
object(a) from customer c where c.i in (1,2)
the query fetches records for which
a. i is
in position 1
b. i is
in position 2
c. i is
either in position 1 0r 2
d. none
49. which
for the foll is specified while converting java.util.Date to native SQL type
a. java.persistence.DateType
b. java.persistence.TemporalType
c. java.persistence.SysDateType
d. java.persistence.CalenderType
50. Isolation
levels can be specified by
a. Deployment
descriptor
b. Annotation
C. None
Objective Java Multiple Choice Questions Part 4
31. Remote
interface call by container is
a. Remote
/ local based on container
b. Flexible
to make remote call as network call
c. Always
network call
d. Local
call
32. EJB QL
must have(CB)
a. Select
and from
b. Select
and where
c. Select
, from and where
d. Based
on DB schema
e. can
accept parameters(could be)
33. Attribute
that helps to create a new txn using the existing txn
a. Supports
b. Not
supported
c. Required
d. Requires
new
e. Never
34. Isolation
level for removing dirty reads, phantom and repeated reads
a. TRANSACTION_COMMITTED
b. Serializable
35. Which
of the following is used when a stateful bean calls a stateless bean from the
same container
a. Local
b. Remote
c. Any
36. MDB is
a. Stateful
bean
b. Stateless
session bean
37. Deployment
descriptor in EJB 3.0 (CB)
a. Same
as 2.0
b. Not
needed as annotations are used
c. Must
be used when necessary
38. Primary
key denoted using
a. @Id
39. Jboss
detects code changes, deploys those files……
a. True
b. False
40. Which
of the following is not used to transform a POJO – entity
i. DAO
Objective Java Multiple Choice Questions Part 3
21. Not a
txn attribute
a. Support
b. Supports
c. Supporting
d. Supported
e. None
22. Cache-idle-timeout-seconds
means
a. Application
turns off caching after timeout
b. Idle
beans are destroyed from memory after timeout
c. Idle
beans are passivated after timeout
23. Advantages
of messaging (CB)
a. Synchronous
b. Decoupling
c. Reliability
d. Multiple
sender & receiver
e. All
24. JANE,JAYME,ANN
Select C from Customer where name like ‘_A%E%’
The query returns :
a. None
b. JAYME
c. JANE
d. ANN
25. EJB QL
used for (CB)
a. Finder
methods
b. Select
methods
c. Create
methods
d. Home
business methods
26. Why
client txn is not advisable in EJB
a. Decreases
speed
b. Small
granularity
c. DB
locks
d. Should
be used
27. Advantages
of using session bean for calling entity beans (CB)
a. BMP
b. No
dependency injection
c. CMP
d. Dependency
injection
28. Which
bean is best in performance
a. Stateful
b. BMP
c. CMP
d. MDB
29. Session
bean / entity bean throws __________ exception and MDB throws ______ exception
a. Remote,remote
b. No
exception,RMI
c. RMI,remote
d. Remote,no
exception
30. Authentication
of credit card when swiped is done by
a. Stateless
b. Steteful
c. Entity
d.
Stateless + MDB
Objective Java Multiple Choice Questions Part 2
11. “More
persistence involving relational database “
a. BMP
b. Stateful
c. Stateless
d. CMP
12. Transactions
can be controlled by (CB)
a. Lazy
loading
b. Turning
off auto-comit
c. TX_REQUIRED
d. Cannot
be controlled completely
13. Which of
the following is implemented in EJB when you want full control over transaction
a. Management
API
b. Leave
it to the container
c. JTA
API
d. JDBC
API
14. Select
Object (A) from Customer As A
Select C From Customer A
The above two are equivalent
a. True
b. False (not
sure)
15. In
container managed txn the attributes are defined through (CB)
a. Dependency
Injection
b. Annotations
c. Deployment
descriptor
16. MDB
interface extends
a. Javax.ejb.SessionInterface
b. Javax.ejb.StatefulInterface
c. Javax.ejb.StatelessInterface
d. Javax.ejb.EnterpriseInterface
17. No
large granularity by(verify)
a. Stateless
SB(sl - ans)
b. Multiple
java classes
c. Multiple
DB tables
d. Business
methods and encapsulating business rules
18. Persistence
is achieved through
a. Transaction
models
b. Java
object serialization & ORM
c. ORM
d. Java
object serialization
19. EJB
access data rows with no business logic in them
a. True
b. False
20. Entities
are remotely accessible
a. True
b. False
Subscribe to:
Posts (Atom)