0% found this document useful (0 votes)
58 views11 pages

Udacity Java Questions

The document contains a series of questions related to Java programming concepts, including ActiveMQ, Java Servlets, EJB, Hibernate, and design patterns. Each question presents multiple-choice answers on topics such as message queues, HTTP requests, method overriding, and Java 8 features. The questions are aimed at testing knowledge of Java and its associated technologies.

Uploaded by

dpalak0607
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
58 views11 pages

Udacity Java Questions

The document contains a series of questions related to Java programming concepts, including ActiveMQ, Java Servlets, EJB, Hibernate, and design patterns. Each question presents multiple-choice answers on topics such as message queues, HTTP requests, method overriding, and Java 8 features. The questions are aimed at testing knowledge of Java and its associated technologies.

Uploaded by

dpalak0607
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

Question 2

Active Message Queue also supports priority consumption (using priority queue) so
that high priority messages are consumed before low priority message. Which of the
following attribute sets a priority queue in place for ActiveMQ?

 prioritizedMessages="true"
 prioritizedMessages="false"
 msg.priotyQueue=1
 msg.priotyQueue=2

Question 3
In Deployment descriptor which sub element in <listener> tag helps in declaring a
listener?

 servlet
 servlet-mapping
 listener-name
 listener-class

Question 4
Answer the below question based on Java Servlets concepts.
For the URL given below which of the following HTTP request gets generated?
http://www.example.com/abcd/index.html

 GET
 POST
 HEAD
 NET

Question 5
Which one of the following is equivalent to line 1? (Choose the most appropriate
option)
interface ITest1 {
void show(); // Line 1
}
 public final not final
 public abstract not final
 static abstract not final
 hide data not final

Question 6
putIfAbsent(key, value) is a part of which collection?

 ConcurrentMap
 HashMap
 ArrayList
 SortedMap

Question 7
The field in an interface is implicitly defined as ______

 static
 public
 final
 All of the above

Question 8
Which of the following is used to achieve runtime polymorphism?

 Method overriding
 Method overloading
 Return type
 Virtual function

Question 9
What will be the output of the following code?

java
class DemoCode {
public static void main(String arg[]) {
byte b = 1;
b += 1;
System.out.println(b);
}
}

 1
 2
 12
 None of these

Question 10
Which of the following interface contains hasPrevious() method?

 Iterator
 ListIterator
 Both
 None of the above

Question 11
As per EJB concepts, in a primary key class, what is the purpose of the equals() and
hashCode() methods?

 The given methods are required so that if there is an exception in the instance while
getting the value from store, the store should give the correct value that logic is similar
to get/store and post results() in EJB 1.x
 The equals() method returns a boolean value when PKs filter the hashCode() value - a
method used for validating when the PK is number
 The equals() method returns a boolean value indicating if the object is equal so that the
hashCode() is used by container to check the actual implementation for PK for the
primary key
 The equals() method returns a boolean value indicating if the object is equal so that the
hashCode() is used by container to check the actual implementation for PK for the
primary key

Question 12
As per EJB concepts, is it possible to have a static initializer block in EJB?
 It's not possible to have static initializer block in EJB
 It is technically possible but it is not supported
 Compiler would not complain but run time exception would be thrown
 None of the given options

Question 13
Which of the following method is added to Map in Java 9?

 static Map.of(K, V), K1, V1, K2, V2, K3, V3


 Map.ofEntries(K1, V1, K2, V2, K3, V3)
 Both Option 1 and 2
 None

Question 14
Answer the following questions based on your knowledge of JSP. Which of the
following method if called from a JSP page would produce an unpredictable result?

 do_post()
 system.out.println()
 system.exit(0)
 none of the above

Question 16
What does session.createQuery(Query).scroll() return?

 ListResultSet
 ResultSet
 ScrollableResultSet
 ScrollableResult

Question 17
Which of the following can be used in place of 'Overloading'?

 Virtual polymorphism
 Transient polymorphism
 Ad hoc polymorphism
 Pseudo polymorphism

Question 18
What does SAM stand for in context of Functional Interface?

 Single Abstract Marker


 Simple Abstract Marker
 Single Abstract Method
 Simple Abstract Markup

Question 20
Select the single most appropriate description of Lambda expression from the
following four choices.

 Lambda expression represents Java syntax for defining mathematical expression in Java
 Lambda expression is a way of introducing inline delegate (think C# style) in Java
expression
 Lambda expression is a way of creating code as data, for example passing some
functionality as a parameter
 None of the above

Question 21
Which of the following data structures is likely to be used by a HashMap to handle
collisions?

 Linked List
 Stack
 Queue
 Binary Tree

Question 22
What are the two types of Streams offered by Java 8?
 Parallel and Random
 Sequential and Random
 Sequential and Parallel
 Random and Performance

Question 1
Which of the following method is used to delete all the messages in a queue?

 delete
 remove
 redo
 purge

Question 13
Which of the following method is added to Map in Java 9?

 static Map.of(K1,V1,K2,V2,K3,V3)
 Map.ofEntries(K1,V1,K2,V2,K3,V3)
 Both Option 1 and 2
 None

Question 16
Which of the following connection pools is best for Hibernate?

 c3p0
 proxool
 DBCP
 HikariCP

Question 23
Which of the following is not introduced with Java 8?

 Stream API
 Lybdaum
 Removal of PermGen
 Serialization
 Lambda Expressions

Question 45
Answer the following questions based on your knowledge of Hibernate. Which of these
is a tag of the class hibernate.cfg.xml?

 DTD
 Mapping files
 JDBC connection configuration
 Mapping files and JDBC connection configuration

Question 46
Choose the correct option. Which of the following operations is not supported by
Hibernate Query Language?

 Create
 Insert
 Select
 None of the above

Question 47
Choose the correct option. Assuming Cat, Apple, Bears, Dogs, Sparrows, Pigeons are
persistence classes in an application, which of the following HQL statements returns all
persistent objects of a Hibernate application?

 from pCat as cat


 from exApple as apple, exBears as bears
 from java.lang.object obj
 none of the above

Question 49
Which of the following correctly describes the ifPresentOrElse() method of Optional
class?
 If a value is present it returns a sequential Stream containing only that value, otherwise
returns an empty Stream.
 If a value is present, performs the given action with the value, otherwise performs the
given empty-based action.
 Both Option 1 and 2
 None

Question 50
Which of the following is not introduced in Java 9?

 MultiRelease JAR
 Private Methods in Interfaces
 Lambda expressions
 HTML5 based java documentation

Question 17
Which of the following are correct with regard to the given code?

java
class Parent {
void display(int i) { }
}
class Child extends Parent {
void display(int i) { }
void display() { }
}

 The methods in lines 2 and 8 are overriding, the methods in lines 5 and 11 are
overloaded
 The methods in lines 2 and 8 are overloaded, the methods in lines 5 and 11 are
overriding
 The methods in lines 2, 4, and 11 are overloaded
 The methods in lines 2, 4, and 11 are overridden
 Compile-time exception in line 11

Question 19
Which of the following data structures is likely to be used by a TreeMap?
 Binary Search Tree
 Hash Table
 Red Black Tree
 Array

Question 20
Which feature of Java 8 enables us to create a work stealing thread pool using all
available processors at its target to maintain enough threads for supporting the given
parallelism level?

 workLoad
 threadPool
 workThreadPool
 newWorkStealingPool

Question 21
One of the differences between Collection API and Stream API is that the later can be
used to process either limited or infinite number of elements. Select the correct option:

 TRUE
 FALSE

Question 22
How can the Advanced Encryption Standard (AES) be disabled using the Java VM
Option?

 Using -XX:+UseAES and -XX:+HasAESIntrinsics


 Using -XX:-UseAES-disable and -XX:-HasAESIntrinsics-disable
 Using -XX:-UseAES-disable and -XX:+HasAESIntrinsics-disable
 Using -XX:+UseAES-disable and -XX:-HasAESIntrinsics-disable

Question 25
Which of the following statements about stubs and skeletons is true?
 Stubs and skeletons are implemented by the developer
 Stubs and skeletons are generated automatically by the RMI compiler
 Stubs and skeletons are a part of session and entity beans
 None of the given options

Question 26
As per EJB concepts in every EJB JAR file, which of the following options must be
included?

 Stubs for the EJBHome and EJBObject interface, A deployment descriptor



1. The JAR Manifest file 2. The EJB Home interface

1. A deployment descriptor 2. The EJB home interface

1. The NDI context 2. The JAR Manifest File

Question 27
Answer the below question based on JSP concepts. What is the difference between
HttpServletResponse redirect method and RequestDispatcher's forward method?

 RequestDispatcher forward a request from a servlet to another resource on the server.


HttpServletResponse redirect temporary redirect response to the client using the
specified redirect Location URL.
 RequestDispatcher forward method temporarily redirect response to the client using
the specified redirect location URL. HttpServletResponse redirect a request from the
servlet to another resource on the server.
 RequestDispatcher forward can forward the request to outside the container for
example www.yahoo.com
 None of these

Question 31
As per design patterns concepts, which of the following structural patterns uses shared
objects that can be used in multiple contexts simultaneously so as to minimize memory
use?
 Flyweight
 Singleton
 Prototype
 None of the given options

Question 32
Which of the following design patterns address(es) how you can decouple senders and
receivers, but with different trade-offs?

 Chain of responsibility
 Command
 Observer
 All of the given options

Question 9
Which of the following is not a valid method declaration within an interface in Java?

 public String show();


 abstract String show();
 final String show();
 String show();

You might also like