MCQs | EJB/EJB Core Java Mcq Questions Sample Test,Sample questions

Question:
How many methods does a thread class provides for sleeping a thread?

1.3

2.1

3.4

4.2


Question:
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 ______.

1.NullPointerException

2.ArrayIndexOutOfBoundsException

3.ArithmeticException

4.NumberFormatException


Question:
What will happen if we call the run() method directly instead of calling the start() method?

1.Each thread starts in a separate call stack.

2.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.

3.Both A & B

4.None of the above


Question:
Which are subclasses of FilterInputStream and FilterOutputStream?

1.PipedInputStream

2.PipedOutputStream

3.DataInputStream

4.Both C & D


Question:
Which package includes StringTokenizer that tokenizes a string into independent words?

1.java.awt

2.java.applet

3.java.util

4.java.lang


Question:
Which string function returns the number of characters in a string?

1.length()

2.replace()

3.charAt()

4.equalIgnoreCase()


Question:
A class is declared inside a class but outside a method it is known as ________.

1.Anonymous Inner class

2.Member Inner class

3.Local Inner class

4.Static nested class


Question:
Abbreviate the term JMS?

1.Java Message Servic

2.Java Monitor Service

3.Java Message Session

4.Java Monitor Session


Question:
EJB is like COM Abbreviate the term COM?

1.Component Object Model

2.Component Oriented Model

3.Common Object Model

4.Common Oriented Model


Question:
From the following statements which is a disadvantage of an java array?

1.An array can hold primitive types data

2.An array has its size that is known as array length

3.An array knows only its type that it contains. Array type is checked at the compile-time

4.An array holds only one type of data


Question:
hich Exception occurs when a class is not found while dynamically loading a class using the class loaders?

1.ClassNotFoundException

2.ClassFoundException

3.NoClassDefFoundError

4.ClassDefFoundError


Question:
How many reserved keywords are currently defined in the Java language?

1.48

2.49

3.50

4.47


Question:
How many types of constructor are defined in the StringTokenizer class?

1.2

2.3

3.4

4.5


Question:
How many types of session beans are available in EJB?

1.2

2.3

3.4

4.5


Question:
How many ways are there to access package from another package?

1.3

2.2

3.1

4.5


Question:
If a subclass has the same method as declared in the parent class it is known as ______.

1.Method overriding

2.Method overloading

3.Constructor overloading

4.None of the above


Question:
JVM stands for?

1.Java Very Large Machine

2.Java Verified Machine

3.Java Very Small Machine

4.Java Virtual Machine


Question:
Mutual exclusive and inter-thread communication are which type of Synchorization?

1.Thread Synchronization

2.Process Synchronization

3.Object Synchronization

4.None of the above


Question:
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.

1.Parameterized constructor

2.Default Constructor

3.Overloading Constructor

4.None of the above


Question:
The following program is an example of?class Simple{public static void main(String args[]){String s=Sachin;System.out.println(s.length());//6}}

1.length() method

2.intern() method

3.trim() method

4.charAt() method


Question:
The following Syntax is used for?class Subclass-name extends Superclass-name{//methods and fields}

1.Polymorphism

2.Encapsulation

3.Inheritance

4.None of the above


Question:
Under which package is the string class encapsulated?

1.java.lang

2.java.util

3.java.io

4.java.awt


Question:
What are the main subclasses of the Exception class?

1.IOException class

2.RuntimeException Class

3.ClassCastException

4.Both A & B


Question:
What can be accessed or inherited without actual copy of code to each program?

1.Application

2.Browser

3.Package

4.None of the above


Question:
What is known as the classes that extend Throwable class except RuntimeException and Error?

1.Checked Exception

2.Unchecked Exception

3.Error

4.None of the above


Question:
What is the advantage of Method Overloading?

1.Method overloading increases the readability of the program

2.Method overloading does not increases the readability of the program

3.Method overloading does not increases the reliability of the program

4.None of the above


Question:
What is the range of the int data type?

1.+2147483648 to 2147483647

2.-2147483647 to 2147483648

3.-32768 to 32767

4.-32767 to 32768


Question:
What represents a persistent global data from the database?

1.Entity Bean

2.Session Bean

3.Both A & B

4.None of the above


Question:
What type of constructor is used to provide different values to the distinct objects?

1. Default constructor

2.Parameterized constructor

3.Overloading constructor

4.None of the above


Question:
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.

1.JVM

2.JDK

3.JRE

4.None of the above


Question:
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?

1.Private

2.Public

3.Protected

4.None of the above


Question:
Which case of a session bean obtains the UserTransaction object via the EJBContext using the getUserTransaction() method in EJB transaction management?

1.Bean-managed transactions

2.Container-managed transactions

3.Both A & B

4.None of the above


Question:
Which class is thread-safe i.e. multiple threads cannot access it simultaneouslySo it is safe and will result in an order?

1.StringBuffer class

2.StringBuilder class

3.Both A & B

4.None of the above


Question:
Which class is used to uncompress the file in the deflate compression format It provides facility to the other uncompression filters?

1.DeflaterOutputStream class

2.InflaterInputStream class

3.Both A & B

4.None of the above


Question:
Which class is used when a program does not want to handle an exception?

1.Throws

2.Try

3.Catch

4.Final


Question:
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?

1.private

2.Public

3.Protected

4.None of the above


Question:
Which classes has Sun Microsystem suggested not to use for read and write the textual information?

1.BufferedInputStream and BufferedOutputStream

2.SequenceInputStream and SequenceOutputStream

3.FileInputStream and FileOutputStream

4.Both A & B


Question:
Which component does the Entity bean represent the persistent data stored in the database?

1.Server-side component

2.Client-side component

3.server and client side component

4.None of the above


Question:
Which component does the Entity bean represents the persistent data stored in the database?

1.Server-side component

2.Client-side component

3.server and client side component

4.None of the above


Question:
Which constructor creates an empty string buffer with the specified capacity as length.

1.StringBuffer()

2.StringBuffer(String str)

3.StringBuffer(int capacity)

4.None of the above


Question:
Which field of StreamTokenizer if the token is a word this filed contains the word that can be used in programming?

1.String sval

2.double nval

3.int ttype

4.static final int TT_WORD


Question:
Which is a mechanism where one object acquires all the properties and behaviors of the parent object?

1.Inheritance

2.Encapsulation

3.Polymorphism

4.None of the above


Question:
Which is a superclass of all exception classes?

1.Throwable

2.Exception

3.RuntimeException

4.IOException


Question:
Which is a technique in Java in which a class can have any number of constructors that differ in parameter lists?

1.Constructor overloading

2.Method overloading

3.Operator overloading

4.None of the above


Question:
Which is irrecoverable?

1.Error

2.Checked Exception

3.Unchecked Exception

4.Both B & C


Question:
Which is used for reading streams of raw bytes such as image data and for reading streams of characters consider using FileReader?

1.FileInputStream

2.FileOutputStream

3.Both A & B

4.None of the above


Question:
Which is used to separate the hierarchy of the class while declaring an import statement?

1.Package

2.Applet

3.Browser

4.All of the above


Question:
Which keyword is used by classes to implement an interface?

1.import

2.implements

3.instance of

4.None of the above


Question:
Which keyword is used to make the classes and interface of another package accessible to the current package?

1.Import

2.Implements

3.Instanceof

4.None of the above


Question:
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?

1.Inter-thread communication

2.Initial-thread communication

3.Mutual Exclusive

4.None of the above


Question:
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.

1.public final void wait(long timeout)throws InterruptedException

2.protected void finalize()throws Throwable

3.public final void wait(long timeoutint nanos)throws InterruptedException

4.protected Object clone() throws


Question:
Which method in thread class causes the currently executing thread object to temporarily pause and allow other threads to execute?

1.public boolean isAlive()

2.public int getId()

3.public void yield()

4.public boolean isDaemon()


Question:
Which method is used in thread class to starts the execution of the thread?

1.public void start()

2.public void run()

3.public void stop()

4.public void suspend()


Question:
Which method is used to change the name of a thread?

1.public String getName()

2.public void setName(String name)

3.public void getName()

4.public String setName(String name)


Question:
Which method is used to invoke the garbage collector to perform the cleanup processing?

1.gc() method

2.finalize() method

3.q.get() method

4.None of the above


Question:
Which method of DataInputStream class reads a line from the file and returns it as a string?

1.WriteInt()

2.readLine()

3.readInt()

4.writeDouble()


Question:
Which method of string class in java is used to convert the boolean into String?

1.public static String valueOf(double I)

2.public static String valueOf(boolean I)

3.public boolean equals(Object anObject)

4.public static String valueOf(Object obj)


Question:
Which method returns a reference to the currently executing thread object?

1.currentThread()

2.runningThread()

3.runnableThread()

4.None of the above


Question:
Which method returns the interrupted flag after that it sets the flag to false if it is true?

1.isInterrupted()

2.static interrupted()

3.non static interrupted()

4.Both A & C


Question:
Which method waits for a thread to die?

1.stop()

2.start()

3.terminate()

4.join()


Question:
Which methods are provided by the PrintStream class?

1.Read data to another stream

2.Write data to another stream

3.Read data to same stream

4.Write data to same stream


Question:
Which middleware services are provided by EJB?

1.Security

2.Transaction Management

3.Both A & B

4.None of the above


Question:
Which package includes all the standard classes of java?

1.java.lang

2.java.math

3.java.ref

4.java.util


Question:
Which package is used for GUI?

1.java.lang

2.java.awt

3.java.lang.ref

4.java.io


Question:
Which packages are also termed as Java API Packages?

1.Java System Packages

2.User Defined Package

3.Java Defined Packages

4.None of the above


Question:
Which provides a new way for your programs to interface with code libraries written in other languages?

1.JNI

2.JDBC

3.RMI

4.GUI


Question:
Which provides accessibility to classes and interface?

1.import

2.Static import

3.All the above

4.None of the above


Question:
Which server-side component is required to be deployed on the server?

1.EJB

2.RMI

3.Both A & B

4.None of the above


Question:
Which services are provided to EJB components by the EJB container?

1.Transaction support

2.Persistence support

3.Naming support

4.All mentioned above


Question:
Which session bean does the conversational state between multiple method calls is not maintained by the container?

1.Stateful Session Bean

2.Stateless Session Bean

3.Singleton Session Bean

4.�None of the above


Question:
Which session bean maintain their state between client invocations but are not required to maintain their state across server crashes or shutdowns?

1.Stateful Session Bean

2.Stateless Session Bean

3.Singleton Session Bean

4.None of the above


Question:
Which state is the thread still alive but is currently not eligible to run?

1.Non-Runnable

2.Terminated

3.Runnable

4.Running


Question:
Which statement provides an easy way to dispatch execution to different parts of your code based on the value of an expression?

1.If

2.Switch

3.Nested-if

4.if-else-if


Question:
Which stream does Java application uses to read data from a source it may be a file an array peripheral device or socket?

1.InputStream

2.OutputStream

3.Input/OutputStream

4.None of the above


Question:
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?

1.Brackets

2.Braces

3.Parentheses

4.Semicolon


Question:
Which Thread pool is used where container creates a thread pool to process the request?

1.Servlet

2.JSp

3.All of the above

4.None of the above


Question:
Which type of inheritance one super-class have more than one sub-class?

1.Hierarchical inheritance

2.Single inheritance

3.Multiple inheritances

4.Multilevel inheritance


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

1.Message-Driven Bean

2.Session Bean

3.Entity Bean

4.None of the above


Question:
Which variables are created when an object is created with the use of the keyword new and destroyed when the object is destroyed?

1.Local variables

2.Instance variables

3.Class Variables

4.Static variables


Question:
Who is also called father of Java Programming Language?

1.James Gosling

2.Ken Thompson

3.Dennis Richie

4.None of the above


More MCQS

  1. EJB Core Java Mcq Questions
  2. EJB MCQ - Java Technologies
Search