Olete.in
Articles
Mock Tests
🧪 EJB MCQ Quiz Hub
EJB Core Java Mcq Questions
Choose a topic to test your knowledge and improve your EJB skills
1. Which services are provided to EJB components by the EJB container?
Transaction support
Persistence support
Naming support
All mentioned above
2. Which case of a session bean obtains the UserTransaction object via the EJBContext using the getUserTransaction() method in EJB transaction management?
Bean-managed transactions
Container-managed transactions
Both A & B
None of the above
3. Abbreviate the term JMS?
Java Message Servic
Java Monitor Service
Java Message Session
Java Monitor Session
4. Which session bean maintain their state between client invocations but are not required to maintain their state across server crashes or shutdowns?
Stateful Session Bean
Stateless Session Bean
Singleton Session Bean
None of the above
5. Which component does the Entity bean represent the persistent data stored in the database?
Server-side component
Client-side component
server and client side component
None of the above
6. EJB is like COM Abbreviate the term COM?
Component Object Model
Component Oriented Model
Common Object Model
Common Oriented Model
7. What represents a persistent global data from the database?
Entity Bean
Session Bean
Both A & B
None of the above
8. Which component does the Entity bean represents the persistent data stored in the database?
Server-side component
Client-side component
server and client side component
None of the above
9. Which middleware services are provided by EJB?
Security
Transaction Management
Both A & B
None of the above
10. Which server-side component is required to be deployed on the server?
EJB
RMI
Both A & B
None of the above
11. How many types of session beans are available in EJB?
2
3
4
5
12. Which type of instances retain no data or conversational state for a specific client?
Message-Driven Bean
Session Bean
Entity Bean
None of the above
13. Which session bean does the conversational state between multiple method calls is not maintained by the container?
Stateful Session Bean
Stateless Session Bean
Singleton Session Bean
�None of the above
14. Which method returns the interrupted flag after that it sets the flag to false if it is true?
isInterrupted()
static interrupted()
non static interrupted()
Both A & C
15. From the following statements which is a disadvantage of an java array?
An array can hold primitive types data
An array has its size that is known as array length
An array knows only its type that it contains. Array type is checked at the compile-time
An array holds only one type of data
16. The following Syntax is used for?class Subclass-name extends Superclass-name{//methods and fields}
Polymorphism
Encapsulation
Inheritance
None of the above
17. Which constructor creates an empty string buffer with the specified capacity as length.
StringBuffer()
StringBuffer(String str)
StringBuffer(int capacity)
None of the above
18. How many reserved keywords are currently defined in the Java language?
48
49
50
47
19. Which mechanism is used when a thread is paused running in its critical section and another thread is allowed to enter (or lock) in the same critical section to be executed?
Inter-thread communication
Initial-thread communication
Mutual Exclusive
None of the above
20. Which method is used to change the name of a thread?
public String getName()
public void setName(String name)
public void getName()
public String setName(String name)
21. Which class is used to uncompress the file in the deflate compression format It provides facility to the other uncompression filters?
DeflaterOutputStream class
InflaterInputStream class
Both A & B
None of the above
22. Which is used for reading streams of raw bytes such as image data and for reading streams of characters consider using FileReader?
FileInputStream
FileOutputStream
Both A & B
None of the above
23. Mutual exclusive and inter-thread communication are which type of Synchorization?
Thread Synchronization
Process Synchronization
Object Synchronization
None of the above
24. Which is irrecoverable?
Error
Checked Exception
Unchecked Exception
Both B & C
25. What is known as the classes that extend Throwable class except RuntimeException and Error?
Checked Exception
Unchecked Exception
Error
None of the above
26. Which methods are provided by the PrintStream class?
Read data to another stream
Write data to another stream
Read data to same stream
Write data to same stream
27. hich Exception occurs when a class is not found while dynamically loading a class using the class loaders?
ClassNotFoundException
ClassFoundException
NoClassDefFoundError
ClassDefFoundError
28. Which method of string class in java is used to convert the boolean into String?
public static String valueOf(double I)
public static String valueOf(boolean I)
public boolean equals(Object anObject)
public static String valueOf(Object obj)
29. Which is used to separate the hierarchy of the class while declaring an import statement?
Package
Applet
Browser
All of the above
30. Which Thread pool is used where container creates a thread pool to process the request?
Servlet
JSp
All of the above
None of the above
31. Which field of StreamTokenizer if the token is a word this filed contains the word that can be used in programming?
String sval
double nval
int ttype
static final int TT_WORD
32. Which statement provides an easy way to dispatch execution to different parts of your code based on the value of an expression?
If
Switch
Nested-if
if-else-if
33. The following program is an example for?class Student{int id;String name;void display(){System.out.println(id+ +name);}public static void main(String args[]){Student s1=new Student();Student s2=new Student();s1.display();s2.display();}}- Published on 20 Jul 15a. b. c. d.
Parameterized constructor
Default Constructor
Overloading Constructor
None of the above
34. If you are inserting any value in the wrong index as shown below1. int a[]=new int[5];2. a[10]=50;it would result in ______.
NullPointerException
ArrayIndexOutOfBoundsException
ArithmeticException
NumberFormatException
35. The following program is an example of?class Simple{public static void main(String args[]){String s=Sachin;System.out.println(s.length());//6}}
length() method
intern() method
trim() method
charAt() method
36. Which provides accessibility to classes and interface?
import
Static import
All the above
None of the above
37. What can be accessed or inherited without actual copy of code to each program?
Application
Browser
Package
None of the above
38. Which variables are created when an object is created with the use of the keyword new and destroyed when the object is destroyed?
Local variables
Instance variables
Class Variables
Static variables
39. Which is a superclass of all exception classes?
Throwable
Exception
RuntimeException
IOException
40. Which access specifiers can be used for a class so that it�s members can be accessed by a different class in the different package?
Private
Public
Protected
None of the above
41. Which keyword is used to make the classes and interface of another package accessible to the current package?
Import
Implements
Instanceof
None of the above
42. Which method returns a reference to the currently executing thread object?
currentThread()
runningThread()
runnableThread()
None of the above
43. Which are subclasses of FilterInputStream and FilterOutputStream?
PipedInputStream
PipedOutputStream
DataInputStream
Both C & D
44. What is the range of the int data type?
+2147483648 to 2147483647
-2147483647 to 2147483648
-32768 to 32767
-32767 to 32768
45. Which is a mechanism where one object acquires all the properties and behaviors of the parent object?
Inheritance
Encapsulation
Polymorphism
None of the above
46. Which class is thread-safe i.e. multiple threads cannot access it simultaneouslySo it is safe and will result in an order?
StringBuffer class
StringBuilder class
Both A & B
None of the above
47. Which is a technique in Java in which a class can have any number of constructors that differ in parameter lists?
Constructor overloading
Method overloading
Operator overloading
None of the above
48. Which class members can be accessed from the classes in the same package as well as classes in other Packages that are subclasses of the declaring class?
private
Public
Protected
None of the above
49. How many methods does a thread class provides for sleeping a thread?
3
1
4
2
50. Under which package is the string class encapsulated?
java.lang
java.util
java.io
java.awt
51. How many ways are there to access package from another package?
3
2
1
5
52. Which state is the thread still alive but is currently not eligible to run?
Non-Runnable
Terminated
Runnable
Running
53. Which method of DataInputStream class reads a line from the file and returns it as a string?
WriteInt()
readLine()
readInt()
writeDouble()
54. What type of constructor is used to provide different values to the distinct objects?
Default constructor
Parameterized constructor
Overloading constructor
None of the above
55. Which class is used when a program does not want to handle an exception?
Throws
Try
Catch
Final
56. How many types of constructor are defined in the StringTokenizer class?
2
3
4
5
57. Which package includes all the standard classes of java?
java.lang
java.math
java.ref
java.util
58. What will happen if we call the run() method directly instead of calling the start() method?
Each thread starts in a separate call stack.
Invoking the run() method from main thread the run() method goes onto the current call stack rather than at the beginning of a new call stack.
Both A & B
None of the above
59. Which method waits for a thread to die?
stop()
start()
terminate()
join()
60. Which package includes StringTokenizer that tokenizes a string into independent words?
java.awt
java.applet
java.util
java.lang
61. JVM stands for?
Java Very Large Machine
Java Verified Machine
Java Very Small Machine
Java Virtual Machine
62. Which keyword is used by classes to implement an interface?
import
implements
instance of
None of the above
63. A class is declared inside a class but outside a method it is known as ________.
Anonymous Inner class
Member Inner class
Local Inner class
Static nested class
64. Which default exception handler that performs the following tasks:- Prints out exception description.- Prints the stack trace (Hierarchy of methods where the exception occurred).- Causes the program to terminate.
JVM
JDK
JRE
None of the above
65. Which string function returns the number of characters in a string?
length()
replace()
charAt()
equalIgnoreCase()
66. Who is also called father of Java Programming Language?
James Gosling
Ken Thompson
Dennis Richie
None of the above
67. Which classes has Sun Microsystem suggested not to use for read and write the textual information?
BufferedInputStream and BufferedOutputStream
SequenceInputStream and SequenceOutputStream
FileInputStream and FileOutputStream
Both A & B
68. Which provides a new way for your programs to interface with code libraries written in other languages?
JNI
JDBC
RMI
GUI
69. What is the advantage of Method Overloading?
Method overloading increases the readability of the program
Method overloading does not increases the readability of the program
Method overloading does not increases the reliability of the program
None of the above
70. Which symbol is used to contain the values of automatically initialized arrays. Also used to define a block of code for classes methods and local scopes?
Brackets
Braces
Parentheses
Semicolon
71. Which packages are also termed as Java API Packages?
Java System Packages
User Defined Package
Java Defined Packages
None of the above
72. Which method is used in thread class to starts the execution of the thread?
public void start()
public void run()
public void stop()
public void suspend()
73. Which stream does Java application uses to read data from a source it may be a file an array peripheral device or socket?
InputStream
OutputStream
Input/OutputStream
None of the above
74. Which type of inheritance one super-class have more than one sub-class?
Hierarchical inheritance
Single inheritance
Multiple inheritances
Multilevel inheritance
75. If a subclass has the same method as declared in the parent class it is known as ______.
Method overriding
Method overloading
Constructor overloading
None of the above
76. Which method is used to invoke the garbage collector to perform the cleanup processing?
gc() method
finalize() method
q.get() method
None of the above
77. What are the main subclasses of the Exception class?
IOException class
RuntimeException Class
ClassCastException
Both A & B
78. Which method causes the current thread to wait for the specified milliseconds until the another thread notifies? (invokes notify() or notifyAll() method)?a. b. c. d.
public final void wait(long timeout)throws InterruptedException
protected void finalize()throws Throwable
public final void wait(long timeoutint nanos)throws InterruptedException
protected Object clone() throws
79. Which package is used for GUI?
java.lang
java.awt
java.lang.ref
java.io
80. Which method in thread class causes the currently executing thread object to temporarily pause and allow other threads to execute?
public boolean isAlive()
public int getId()
public void yield()
public boolean isDaemon()
Submit