Sei sulla pagina 1di 5

1.

50 numbers ( 1 to 50 ) are distributed in random order in an array of size


50. One number is missing. How to find.
Ans: int sum = 0;
int idx = -1;
for (int i = 0; i < arr.length; i++) {
if (arr[i] == 0) {
idx = i;
} else {
sum += arr[i];
}
}

// the total sum of numbers between 1 and arr.length.


int total = (arr.length + 1) * arr.length / 2;

System.out.println("missing number is: " + (total - sum) + " at index " + idx);

2. Inner Classes, Anonymous Classes.


4. Serialization.
6. Write logic to print alternate elements in a ArrayList, even some are removed.
7. How to implement a Hospital scenario, where doctor is examining patients, and
emergency cases, and informing doctor of emergency cases, scheduling, etc.
8. How to select unique elements from a table.
9. Calculate number of legs, and give formula:
7 persons, each person having 7 bags, each bag having 7 dogs, and each dog having 7
puppies.
1. How is semaphore implemented.
2. How to ensure only one instance in Singleton class.
3. How synchronization works, inside JVM.

Java's monitor supports two kinds of thread synchronization: mutual exclusion


and cooperation. Mutual exclusion, which is supported in the Java virtual
machine via object locks, enables multiple threads to independently work on
shared data without interfering with each other. Cooperation, which is supported
in the Java virtual machine via the wait and notify methods of class Object,
enables threads to work together towards a common goal.

4. Master JVM is holding objects. Slave JVM's are reading and writing the object.
What problems can come and what is solution.
5. How Garbage Collection works in JVM.
6. When are class garbage collected, when are classes unloaded.
7. How to ensure that instance is never garbage collected.
8. Different protocols for Web Services.
9. Managing Session in Web Services
10. RMI, how EJB works
11. passing objects between two JVM's.
12. role of WSDL, stubs, etc. in Web Services.
13. Garbage Collection Tuning parameters.
14. LAZY Loading in ORM.
15. Why there is Stack and heap in JVM. Why this structure.
16. how much memory a program consumes, when no objects created inside program.
1. JCA - Tntro
2. JPA - Intro
3. EAGER/ LAZY loading
4. JPA relations
5. IBM MQ Objective
6. JMS session, Thread Safety In JMS
7. JMS providers
8. JMS implementation
9. AQ Provider and implementation using JNDI
10. Garbage Collection algorithms.
11. SOAP
12. JTA.
1. Hashing Algorithm.
2. Search Algorithm
3. MVC design Pattern.
4. Multi threading Objectives.
5. Design Application which handles a particular operation for millions of trades,
operation like trade validation. Application communicates external application for data.
6. Several Designing Questions.
7. Scala, Open Source high performing JMS implementations, Dynamic languages
8. Cache Implementation.
9. How Oracle Coherence works.
1. Why Use EJB 3.0
2. Why use JPA
3. Why use JPA with ORM, Standard ORM products
4. Writing Complex Query while using JPA and ORM
5. JTA, how it works
6. JTA, how to use
7. Where to use JDBC and where ORM
8. JSF Architecture, who is model, view and controller
9. Optimistic Lock in JPA - Detailed
10. Multithreaded program to read large file/ code and design
1. Latch, Barrier, synchronized, Lock, ThreadPoolExecuter, Garbage Collection Algo.
2. Which forums do you follow, Cloud Computing, How to improve programming and
Coding skills.
3. Design hrose racing application.
4. Struts, how to extend struts. Why to use Struts.
5. Where to use messaging
1. Core Java SCJP level
2. Current Project Architecture
3. Message Flow in current project.
4. Fault Tolerance in JMS
5. Hashing Algo in Java, HashMap
6. Aggregation, Composition, Encapsulation, Abstraction.
7. How to implement Thread Pool
8. Complete Garbage Colection Algo.
9. DataSource, DB connection pool - how it works.
10. Exception- Logic, how to handle and design Exception, Error.
11. NIO-concept, Socket handling using NIO.
12. Adapter Design pattern
13. Stored Proc, Trigger
14. JDK1.5 Thread pool
15. Serialization, Externalization
16. Immutable, FInal, Usage of Final and Immutable
17. Exception handling in the spawned threads
18. RESTful Web Services, JEEVAN
19. Types of Parsers
1. deep copy and shallow copy
2. hash code
3. graceful shutdown of threads
4. NaN, 0/0
5. wrapper classes.
6. BootStrap Class Loader
7. Oracle OCI.
8. Oracle JDBC drivers
9. Oracle Thin and Thick Clients.
10. Oracle Rak
11. MQ API, MQ classes for Java.
12. MessageId, Priority for MQ message.
13. Garbage Collection
14. Java Green Threads
15. Coorelated Sub Queries.
16. Steps to make connection to MQ using Java.
17. Options to set for browsing message in MQ Queue.
18. Client Mode/Bindings Mode.
19. Log4j
1. How would you implement your own Thread Pool.
2. What is NIO
3. Best way to read data from socket using traditional I/O
4. Beat way to read file.
5. How to read characters from InputStream.
6. How Serialization works
7. Synchronization
8. how to implement counter in servlet.
9. how hashtable is thread safe.
10. CharSet, Enocder, Decoder
11. AtomicInteger, volatile, transient.
12. JTA, XA, how XA works, two phase commit.
13. Role of transaction manager in XA transaction.
14. XADataSource, and closing XADataSource.
15. UserTransaction
16. JCA Architecture
1. How would you implement cache in java.
2. How would you implement auto complete using java, jsp.
3. How would you implement a chache with auto complete feature.
4. How to make class immutable.
5. How to serialize immutable class.
6. How to gaurantee message delivery in JMS, fault tolerance
7. Message recovery techniques and redelivery.
8. DROP table.
9. Oracle Stored Procedure or function
10. Struts architecture
11. JSP Exception Handling
12. java Objective SCJP Level
13. java Design Pattern
14. J2EE objective
15. Implementing references
16. UNIX Commands - grep, softlink, hardlink
17. Serializable, Externalizable, Cloneable
JDk 1.5 Collections classes.
Multintreading Concepts - Barrier, Latch, etc.
JMS functioning
SQl Query using JOINS
Java Design pattern - detail
Overloading, Overriding, Comparator, Comparable, hashCode(), equals(), Serializable,
Externalizable, RMI, garbage Collection.

If you have to deal with various formats of String in a file, read those
, parse those and write another file with a different formatted String,
how would you approach this using Java Technology?

What happens when a database connection pool , creates many JDBC


database
connections and keep those active, how are the concurrencies of same
user
sessions handled at database level/side?

What are the memory leak possibilities in Java based application


and how to resolve those

Can you explain/provide a business case for Abstract Factory Design


Pattern?

Can you be able to co-relate different categories of design patterns


like
creational pattern, structural pattern, behavioral pattern with Object
Oriented
programming principles like abstraction, encapsulation, inheritence,
polymorphism
etc?

To my understanding, creational pattern can be referred to as


Encapsulation and
Abstraction. Structural pattern can be referring to inheritence and
behavioral
pattern can be referring to polymorphism OO Principles
Which core J2EE Design pattern can be treated in somewhat similar to
Servlet Filters
from Java Servlet 2.3?

Intercepting Filter core J2EE Design Pattern.

Have you noticed java.io.OutputStream related changes in class


definition in Java 5.0, over Java 1.4?

In Java 1.4 OutputStream is an abstract class extending Object


but in Java 5.0, OutputStream is an abstract class extending Object
and implementing Closeable and Flushable interfaces.
Some of these interfaces like Appendable, Readable, Iterable
etc are added.

Is there any ways of getting a chunk of Data from database


at a time without really iterating through resultset while
using database?
What is difference between a web server and a J2EE Web container

Will be a Singleton object be visible across web applications, provided


all the web applications are having this singeton class in it?

What is SessionSynchronization in J2EE Technology?

J2EE Interview answer (open for discussion)


In case of Stateful SessionBean, if used to be notified within a
transaction
boundary, in order to synchronize its state with associated
transactions, then
stateful session bean class should implement SessionSynchronization interface
Java Interview Question 2
Can I use a composite key (like combination of multiple keys,
like a String, a Date, a Integer, a Byte), while storing
objects in a Hashtable? Suppose I have to store a Student Object
in a Hashtable provided key for this object are values like
studentName-classroll-dateofBirth combination?

Java Interview Answer


Yes, one way of doing this is by defining a class with studentName,
classRoll, dateOfBirth as fields and overriding equals and hashCode
methods of Object class, appropriately to equate using all these
three field values and hashCode a hash value of these fields.

What is the difference between synchronized method and synchronized


static method in a class?

Java Interview Answer


In case of synchronized method, if a thread invokes this method, it
acquires a object level monitor/lock for the object (whose synchonized
method is called/invoked?). But in case of synchronized static method,
if a thread invokes this static synchonized method, then a class level
monitor/lock is getting acquired for the object(whose synchronized
method is called/ invoked).

Potrebbero piacerti anche