Core Java - Interview Questions and Answers for 'Architect' | Search Interview Question - javasearch.buggybread.com
Javasearch.buggybread.com

Search Interview Questions


 More than 3000 questions in repository.
 There are more than 900 unanswered questions.
Click here and help us by providing the answer.
 Have a video suggestion.
Click Correct / Improve and please let us know.
Label / Company      Label / Company / Text

   



Core Java - Interview Questions and Answers for 'Architect' - 76 question(s) found - Order By Newest

next 30
Frequently asked at Manhattan Associates ( Based on 2 feedback )
  Q1. What is a Lambda Expression ? What's its use ?Core Java
Ans. Its an anonymous method without any declaration.

Lambda Expression are useful to write shorthand Code and hence saves the effort of writing lengthy Code.

It promotes Developer productivity, Better Readable and Reliable code.

  Sample Code for lambda

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     java   java8   lambda expression   architecture     Asked in 58 Companies      expert        frequent

Try 1 Question(s) Test


Frequently asked question in companies using Hibernate.
  Q2. What is Lazy Initialization in Hibernate ?Hibernate
Ans. It's a feature to lazily initialize dependencies , relationship and associations from the Database. Any related references marked as @OneToMany or @ManyToMany are loaded lazily i.e when they are accessed and not when the parent is loaded.

  Sample Code for Lazy Initialization

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     hibernate   lazy loading hibernate   lazy initialization hibernate   architecture     Asked in 77 Companies      Basic        frequent

Try 2 Question(s) Test


Frequently asked.
 Q3. If you are given a choice to use either ArrayList and LinkedList, Which one would you use and Why ?Core Java
Ans. ArrayList are implemented in memory as arrays and hence allows fast retrieval through indices but are costly if new elements are to be inserted in between other elements. LinkedList allows for constant-time insertions or removals using iterators, but only sequential access of elements

1. Retrieval - If Elements are to be retrieved sequentially only, Linked List is preferred.

2. Insertion - If new Elements are to be inserted in between other elements , Linked List is preferred.

3. Search - Binary Search and other optimized way of searching is not possible on Linked List.

4. Sorting - Initial sorting could be pain but lateral addition of elements in a sorted list is good with linked list.

5. Adding Elements - If sufficiently large elements needs to be added very frequently ,Linked List is preferable as elements don't need consecutive memory location.

  Sample Code for ArrayList

  Sample Code for LinkedList

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     java   collections   list   arraylist   linkedlist   difference between   architecture   data structure   ebay     Asked in 2 Companies      basic        frequent

Try 2 Question(s) Test


Recently asked in TCS , Tech Mahindra, HCL , Accenture and Fidelity.
  Q4. Explain Flow of Spring MVC ?Spring
Ans. The DispatcherServlet configured in web.xml file receives the request.

The DispatcherServlet finds the appropriate Controller with the help of HandlerMapping and then invokes associated Controller.

Then the Controller executes the logic business logic and then returns ModeAndView object to the DispatcherServlet.

The DispatcherServlet determines the view from the ModelAndView object.

Then the DispatcherServlet passes the model object to the View.

The View is rendered and the Dispatcher Servlet sends the output to the Servlet container.

Finally Servlet Container sends the result back to the user.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     j2ee   spring   mvc   frameworks   web applications   architecture     Asked in 11 Companies      Basic        frequent


 Q5. What are the ways to avoid LazyInitializationException ?Hibernate
Ans. 1. Set lazy=false in the hibernate config file.

2. Set @Basic(fetch=FetchType.EAGER) at the mapping.

3. Make sure that we are accessing the dependent objects before closing the session.

4. Force initialization using Hibernate.initialize

5. Using Fetch Join in HQL.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     hibernate   lazy loading hibernate   lazy initialization hibernate   lazyinitializationexception   architecture     Asked in 2 Companies

Try 2 Question(s) Test


Frequently asked question in companies using hibernate.
  Q6. Difference between first level and second level cache in hibernate ?Hibernate
Ans. 1. First level cache is enabled by default whereas Second level cache needs to be enabled explicitly.

2. First level Cache came with Hibernate 1.0 whereas Second level cache came with Hibernate 3.0.

3. First level Cache is Session specific whereas Second level cache is shared by sessions that is why First level cache is considered local and second level cache is considered global.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     hibernate   orm   hibernate cache   architecture   technical lead   first level cache vs second level cache     Asked in 18 Companies      Intermediate        frequent


 Q7. What is session tracking and how do you track a user session in servlets?Java EE
Ans. Session tracking is a mechanism that servlets use to maintain state about a series requests from the same user across some period of time. The methods used for session tracking are:

User Authentication - occurs when a web server restricts access to some of its resources to only those clients that log in using a recognized username and password

Hidden form fields - fields are added to an HTML form that are not displayed in the client's browser. When the form containing the fields is submitted, the fields are sent back to the server

URL rewriting - every URL that the user clicks on is dynamically modified or rewritten to include extra information. The extra information can be in the form of extra path information, added parameters or some custom, server-specific URL change.

Cookies - a bit of information that is sent by a web server to a browser and which can later be read back from that browser.

HttpSession- places a limit on the number of sessions that can exist in memory.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     j2ee   servlets   session   session management   web applications   cookies   httpsession   url rewriting   architecture     Asked in 1 Companies


Advanced level question usually asked to senior developers , leads and architects.
 Q8. How does volatile affect code optimization by compiler?Core Java
Ans. Volatile is an instruction that the variables can be accessed by multiple threads and hence shouldn't be cached. As volatile variables are never cached and hence their retrieval cannot be optimized.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     java   java keywords   volatile   synchronization   compiler optimization   variable caching   architecture     Asked in 3 Companies      expert


Advanced level question frequently asked in US based companies. Recently asked in EMC and Intuit.
  Q9. Can you provide some implementation of a Dictionary having large number of words ? Solution
Ans. Simplest implementation we can have is a List wherein we can place ordered words and hence can perform Binary Search.

Other implementation with better search performance is to use HashMap with key as first character of the word and value as a LinkedList.

Further level up, we can have linked Hashmaps like ,

hashmap {
a ( key ) -> hashmap (key-aa , value (hashmap(key-aaa,value)
b ( key ) -> hashmap (key-ba , value (hashmap(key-baa,value)
....................................................................................
z( key ) -> hashmap (key-za , value (hashmap(key-zaa,value)
}

upto n levels ( where n is the average size of the word in dictionary.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     java   collections   hashmap   binary search   search algorithm   advanced   architecture   data structure     Asked in 6 Companies        frequent

Try 1 Question(s) Test


 Q10. What are the benefits of using Spring Framework ?Spring
Ans. Spring enables developers to develop enterprise-class applications using POJOs. The benefit of using only POJOs is that you do not need an EJB container product.

Spring is organized in a modular fashion. Even though the number of packages and classes are substantial, you have to worry only about ones you need and ignore the rest.

Spring does not reinvent the wheel instead, it truly makes use of some of the existing technologies like several ORM frameworks, logging frameworks, JEE, Quartz and JDK timers, other view technologies.

Testing an application written with Spring is simple because environment-dependent code is moved into this framework. Furthermore, by using JavaBean-style POJOs, it becomes easier to use dependency injection for injecting test data.

Spring is web framework is a well-designed web MVC framework, which provides a great alternative to web frameworks such as Struts or other over engineered or less popular web frameworks.

Spring provides a convenient API to translate technology-specific exceptions (thrown by JDBC, Hibernate, or JDO, for example) into consistent, unchecked exceptions.

Lightweight IoC containers tend to be lightweight, especially when compared to EJB containers, for example. This is beneficial for developing and deploying applications on computers with limited memory and CPU resources.

Spring provides a consistent transaction management interface that can scale down to a local transaction

  Sample Code for spring

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     java   spring framework   mvc   spring container   architecture   technical architect   java architect   technical lead  ioc     Asked in 2 Companies      basic        frequent


Very frequently asked in companies using SOA.
  Q11. What are RESTful Web Services ?Rest
Ans. REST or Representational State Transfer is a flexible architecture style for creating web services that recommends the following guidelines -

1. http for client server communication,
2. XML / JSON as formatiing language ,
3. Simple URI as address for the services and,
4. stateless communication.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     java   web services   rest   java   j2ee  architecture     Asked in 14 Companies      intermediate        frequent


Frequently asked to experienced developers. Recently asked in many US interviews.
  Q12. What is database deadlock ? How can we avoid them?Database
Ans. When multiple external resources are trying to access the DB locks and runs into cyclic wait, it may makes the DB unresponsive.

Deadlock can be avoided using variety of measures, Few listed below -

Can make a queue wherein we can verify and order the request to DB.

Less use of cursors as they lock the tables for long time.

Keeping the transaction smaller.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     java   database   architecture     Asked in 7 Companies      expert        frequent


Advanced level question. Recently asked in few Indian service companies ( Based on 3 inputs )
 Q13. What are various types of Class loaders used by JVM ?Core Java
Ans. Bootstrap - Loads JDK internal classes, java.* packages.

Extensions - Loads jar files from JDK extensions directory - usually lib/ext directory of the JRE

System - Loads classes from system classpath.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     java   jvm   memory management   class loaders   bootstrap   extensions   system  classloaders   advanced   technical lead   technical architect     Asked in 7 Companies


  Q14. Difference between SAX and DOM Parser ?Xml
Ans. A DOM (Document Object Model) parser creates a tree structure in memory from an input document whereas A SAX (Simple API for XML) parser does not create any internal structure.

A SAX parser serves the client application always only with pieces of the document at any given time whereas A DOM parser always serves the client application with the entire document no matter how much is actually needed by the client.

A SAX parser, however, is much more space efficient in case of a big input document whereas DOM parser is rich in functionality.

Use a DOM Parser if you need to refer to different document areas before giving back the information. Use SAX is you just need unrelated nuclear information from different areas.

Xerces, Crimson are SAX Parsers whereas XercesDOM, SunDOM, OracleDOM are DOM parsers.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     java   xml   parsers   sax   dom parser   difference   architecture   technical lead   technical architect  markup language   sax vs dom     Asked in 14 Companies        frequent

Try 1 Question(s) Test


 Q15. What things should be kept in mind while creating your own exceptions in Java?Core Java
Ans. All exceptions must be a child of Throwable.

If you want to write a checked exception that is automatically enforced by the Handle or Declare Rule, you need to extend the Exception class.

You want to write a runtime exception, you need to extend the RuntimeException class.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     java   exceptions   exception handling   user defined exceptions   throwable   architecture   library development   technical architect   technical lead


 Q16. Difference between C++ and Java ?Core Java
Ans. Java does not support pointers.

Java does not support multiple inheritances.

Java does not support destructors but rather adds a finalize() method. Finalize methods are invoked by the garbage collector prior to reclaiming the memory occupied by the object, which has the finalize() method.

Java does not include structures or unions because the traditional data structures are implemented as an object oriented framework.

C++ compiles to machine language , when Java compiles to byte code .

In C++ the programmer needs to worry about freeing the allocated memory , where in Java the Garbage Collector takes care of the the unneeded / unused variables.

Java is platform independent language but c++ is depends upon operating system.

Java uses compiler and interpreter both and in c++ their is only compiler.

C++ supports operator overloading whereas Java doesn't.

Internet support is built-in Java but not in C++. However c++ has support for socket programming which can be used.

Java does not support header file, include library files just like C++ .Java use import to include different Classes and methods.

There is no goto statement in Java.

There is no scope resolution operator :: in Java. It has . using which we can qualify classes with the namespace they came from.

Java is pass by value whereas C++ is both pass by value and pass by reference.

Java Enums are objects instead of int values in C++

C++ programs runs as native executable machine code for the target and hence more near to hardware whereas Java program runs in a virtual machine.

C++ was designed mainly for systems programming, extending the C programming language whereas Java was created initially to support network computing.

C++ allows low-level addressing of data. You can manipulate machine addresses to look at anything you want. Java access is controlled.

C++ has several addressing operators . * & -> where Java has only one: the .

We can create our own package in Java(set of classes) but not in c and c++.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     java   c++   difference between java and c++   programming concepts   programming languages   architecture   technical architect   technical lead     Asked in 1 Companies


 Q17. Why Struts 1 Classes are not Thread Safe whereas Struts 2 classes are thread safe ?
Ans. Struts 1 actions are singleton. So all threads operates on the single action object and hence makes it thread unsafe.

Struts 2 actions are not singleton and a new action object copy is created each time a new action request is made and hence its thread safe.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     java   j2ee   mvc frameworks   struts   struts1   struts2   struts 1   struts 2   architecture

Try 1 Question(s) Test


 Q18. What things you would care about to improve the performance of Application if its identified that its DB communication that needs to be improved ?Solution
Ans. 1. Query Optimization ( Query Rewriting , Prepared Statements )

2. Restructuring Indexes.

3. DB Caching Tuning ( if using ORM )

4. Identifying the problems ( if any ) with the ORM Strategy ( If using ORM )

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     java   db   database   hibernate   orm   at&t   overstock.com   performance improvement   architecture   technical lead   architect      intermediate


 Q19. What are strong, soft, weak and phantom references in Java ?Core Java
Ans. Garbage Collector wont remove a strong reference.

A soft reference will only get removed if memory is low.

A weak reference will get removed on the next garbage collection cycle.

A phantom reference will be finalized but the memory will not be reclaimed. Can be useful when you want to be notified that an object is about to be collected.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     java   memory management   jvm   garbage collections   references   strong reference   soft reference   weak reference   phantom reference   architecture     Asked in 2 Companies


 Q20. How Java provide high Performance ?Core Java
Ans. Java uses Just-In-Time compiler to enable high performance. Just-In-Time compiler is a program that turns Java bytecode into instructions that can be sent directly to the processor.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     java   compiler   jvm   bytecode   justintime compiler   architecture


 Q21. How to configure second level cache in Hibernate ?Hibernate
Ans. 1. Configure Provider class in Hibernate configuration file.

2. Add Cache usage tag ( read-only or read-write ) in mapping files ( hbm ).

3. Create an XML file called ehcache.xml and place in classpath which contains time settings and update settings, behavior of cache , lifetime and idletime of Pojos, how many objects are allowed.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     hibernate   orm   hibernate cache   architecture


 Q22. If you are given a choice to implement the code to either Insert a Record or Update if already exist, Which approach will you follow ?

1. Insert into the DB Table. If exception occurs, update the existing record.
2. Check if the record exists and update it if it exists, If not insert a new record.
Solution
Ans. In first case, there would be 2 DB calls in worst case and 1 in best case. In 2nd approach there will be always 2 DB calls.

Decision on the approach should depend on the following considerations -

1. How costly is the call to DB ? Are we using indices , hibernate etc

If calls to DB are costly , 1st approach should be the choice.

2. Exception Book keeping load upon exception.

The benefit of saving 1st call in approach 1 should be bigger than the Book keeping for the exception.

3. Probability of the exception in first apparoach.

If the DB Table is almost empty, it makes sense to follow Approach 1 as majority of the 1st calls will pass through without exception.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     database   insert-update   db exceution plan   db strategy   design   architecture   technical lead


 Q23. What is meant by an "asynchronous event." Give some examples ?Operating System
Ans. An asynchronous event is one that occurs at an unpredictable time outside the control of the program that the CPU is running. It is not "synchronized" with the program.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     j2ee   internet   web application   asynchronus   asynchronus communication   architecture     Asked in 1 Companies


 Q24. Different types of memory used by JVM ?Core Java
Ans. Class , Heap , Stack , Register , Native Method Stack.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     java   jvm   memory management   memory   advanced   architecture   technical architect     Asked in 1 Companies      intermediate        frequent

Try 5 Question(s) Test


 Q25. Can we have multiple servlets in a web application and How can we do that ?Java EE
Ans. Yes by making entries in web.xml

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     j2ee   servlets   servelets   web application   java   web.xml   yes-no   architecture


 Q26. What are some Java related technologies used for distributed computing ?
Ans. sockets, RMI. EJB

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     java   distributed computing   rmi   ejb   sockets   socket   architecture


 Q27. What is DTD ?Xml
Ans. DTD or Document Type Definition is a standard agreed upon way of communication between two parties. Your application can use a standard DTD to verify that data that you receive
from the outside world is valid and can be parsed by your parser.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     xml   markup language   dtd   document type definition   architecture


 Q28. What is XSD ?Xml
Ans. XSD or Xml Schema Definition is an extension of DTD. XSD is more powerful and extensible than DTD

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     java   xml   markup language   xsd   dtd   architecture


 Q29. Difference between socket and servlet ?Java EE
Ans. servlet is a small, server-resident program that typically runs automatically in response to user input.
A network socket is an endpoint of an inter-process communication flow across a computer network.

We can think of it as a difference between door and gate. They are similar as they both are entry points but they are different as they are put up at different areas.

Sockets are for low-level network communication whereas Servlets are for implementing websites and web services

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     java   j2ee   networking   servlet   socket   difference between.java.net   technologies   architecture


 Q30. What is PermGen or Permanent Generation ?Core Java
Ans. The memory pool containing all the reflective data of the java virtual machine itself, such as class and method objects. With Java VMs that use class data sharing, this generation is divided into read-only and read-write areas. The Permanent generation contains metadata required by the JVM to describe the classes and methods used in the application. The permanent generation is populated by the JVM at runtime based on classes in use by the application. In addition, Java SE library classes and methods may be stored here.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     java   jvm   memory management   permgen   permanent generation   advanced   architecture     Asked in 9 Companies      expert


next 30

Help us and Others Improve. Please let us know the questions asked in any of your previous interview.

Any input from you will be highly appreciated and It will unlock the application for 10 more requests.

Company Name:
Questions Asked: