BPB Online LLP
Java Professional Interview Guide
Java Professional Interview Guide
US$ 19.95
The publisher has enabled DRM protection, which means that you need to use the BookFusion iOS, Android or Web app to read this eBook. This eBook cannot be used outside of the BookFusion platform.
Description
Contents
Reviews

An Ultimate Solution to Crack Java interview

Key Features
● Start identifying responses for various interviews for Java architecture.
● Solutions to real Java scenarios and applications across the industry.
● Understand the various perspectives of Java concepts from the interviewer's point of view.

Description
Java Professional Interview Guide aims at helping engineers who want to work in Java.

The book covers nearly every aspect of Java, right from the fundamentals of core Java to advanced features such as lambdas and functional programming. Each concept's topics begin with an overview, followed by a discussion of the interview questions. Additionally, the book discusses the frameworks, Hibernate and Spring. The questions included in each topic will undoubtedly help you feel more confident during the technical interview, which will increase your chances of being selected. You will gain an understanding of both the interviewer and the interviewee's psychology. This book will help you build a solid foundation of Java, the Java architecture, and how to answer questions about Java's internal operations. You will begin to experience interview questions that cover all of Java's major concepts, from object orientation to collections. You will be able to investigate how objects are constructed and what the fundamental properties of OOPs are. Additionally, you will learn how to handle exceptions and work with files and collections.

We'll cover advanced topics like functional programming and design patterns in the final chapters. The section also covers questions on Java web application development. Finally, you will be able to learn how to answer questions using industry-standard frameworks like Spring and Hibernate.

What you will learn
● How to prepare before an actual technical interview?
● You will learn how to understand an interviewer's mindset.
● What kind of questions can be asked and how can they be answered?
● How to deal with cross-examination questions in an interview.

Who this book is for
This book is intended for both new and experienced candidates preparing for the Java Developer Interview. Although the book provides an overview of all Java and J2EE concepts, prior knowledge of basic Java is required.

Table of Contents
1. The Preparation Beyond Technology
2. Architecture of Java
3. Object Orientation in Java
4. Handling Exception
5. File Handling
6. Concurrency
7. JDBC
8. Collections
9. Miscellaneous
10. Functional Programming
11. Design Patterns
12. Basics of Web
13. Spring and Spring Boot
14. Hibernate

About the Author
Mandar Jog is a passionate Java trainer and has been conducting training for the last 15+ years. His expertise areas are Java & J2EE-related technologies like Spring, Spring Boot, and Hibernate, etc. Along with training, he is also a freelance author and has written a book entitled ‘Java 9.0 to 13.0’ under BPB Publications. He also works as a technical reviewer for books based on Java. He is also one of the key panelists in many of the organizations that conduct the technical interviews of Java for fresher and experienced candidates.

Along with this, he is also connected with different organizations and institutions for designing the curriculum of computer engineering. He also conducts Train-the-Trainer sessions for many colleges to connect them with cutting-edge technologies.

LinkedIn Profile: https://www.linkedin.com/in/mandar-jog-javatrainer/

Language
English
ISBN
9789391030056
Cover Page
Title Page
Copyright Page
Dedication Page
About the Author
About the Reviewer
Acknowledgement
Preface
Errata
Table of Contents
1. The Preparation Beyond Technology
Introduction
Structure
Objective
Types of recruitment
On-campus recruitment
Off-campus recruitment
Java career opportunities
Java full stack developer
Java Web developer
Java mobile app developer
Java EE developer
Java API developer
Selection process: pipeline
Telephonic interview
Technical tests
Face-to-face interview
How to choose a career or role?
How well are you prepared?
How to practice for interviews
By attending real interviews
By creating mock interviews
By collecting feedback post-interview
Interview mistakes that you should avoid
Complex and confused answers
Loosing calmness
Giving mugged answers
Trying to be heroic at an interview
What analysis interviewers normally do?
How good are you to do the job?
Are they comfortable to work with you?
Are you motivated enough?
How good and quick are you to learn new tools/technologies?
Do you fit into the team culture?
Mantras to succeed in an interview
Answer the questions correctly and in your own words
Body language matters
Research about company
Check your skills
Understand the job description
Relationship of your personality and job role
Your expectations matter
You have to be flexible
You have to be proactive
Know your resume/CV
You should be trustworthy and a good team player
Conclusion
2. Architecture of Java
Introduction
Structure
Objectives
Java program execution flow
Explain the execution flow of a Java program
Key files in Java
What are different types of files and their significance in Java programming?
Source code file
Byte code file
Why Java is termed as a platform-neutral or independent language?
Java Runtime Environment (JRE)
What is the role of JRE?
What are the components of JRE?
Class loader
What role a class loader plays?
What are the different types of class loaders?
Bootstrap class loader
Extension class loader
System or application class loader
Can you select the ClassLoader manually?
Bytecode verifier
Which verification is carried out by the bytecode verifier?
Why do we need the bytecode verifier along with compiler?
JVM
What role JVM plays in Java execution flow?
Memory management in JVM
Describe the different types of memory areas generated by JVM
Can you increase the heap memory of JVM?
What is “OutofMemoryException?” How can we handle it?
How can you differentiate between stack memory and heap memory?
How JVM executes class?
JIT compiler
What is importance of JIT?
How JIT works internally to choose methods to compile?
Can we have different versions of JIT than the Java version?
Can you disable JIT?
If you disable JIT, what consequences will you face?
What is the difference between JDK, JRE, and JVM?
JVM
JRE
JDK
What are the legal signatures of the main method?
Can we overload main() ?
Will your program execute if you overload the main method?
Can we declare main() as private?
But, if we declare any method, how will JVM find it?
Can we declare main() as non-static?
Will your program execute successfully if you declare main as non-static?
Conclusion
3. Object Orientation
Introduction
Structure
Objective
Class and objects
What is a class?
What are the conventions of designing a class?
What is an object?
What are the characteristic of an object?
What is a constructor? Explain its role
Can we have a private constructor?
Why Java is not called as a 100% object-oriented programming language?
Why all the instance variables have default values in Java?
What are the accessor and mutator methods in Java, and what is their significance?
Object creation
What are the different ways to create objects?
How to create an object using the newInstance method?
How to create a copy of an existing object?
How the clone method is different from copying the reference of an object to another?
How to use the clone method to create a new object?
When your code will throw the CloneNotSupported Exception?
How to serialize an object?
What is de-serialization, and how it generates a new object?
What are the different access specifiers present in Java? Can you explain their significance?
Can we apply a private modifier to class?
Encapsulation
What is encapsulation, and how to achieve that?
Can you explain why we should follow encapsulation, with real-time example?
To achieve complete encapsulation, can we declare the class with a private access specifier?
Inheritance
What is association in Java?
What is composition in Java?
What is the difference between composition and aggregation?
Can you give one example of composition and aggregation?
What is difference between is-a-kind relation and has-a-kind relation in Java?
How do you explain the term coupling?
What do you mean by loose coupling?
What do you mean by tight coupling?
How do you achieve tight coupling, can you explain with a real-time example?
Explain loose coupling in Java with a real-time example?
Can you explain when to use is-a-kind relationship and when to use has-a-kind relationship in Java?
What is abstract class?
What is a final class, and why one need to declare it?
What is a final method?
Can the abstract class contain constructors?
Why abstract classes provide constructors even though they are not instantiated?
What are concrete methods and abstract methods?
Can we declare all the methods of abstract class as a concrete method?
Can we declare an abstract class as final?
Can we have abstract methods as private?
Can we declare abstract methods as static?
Who takes the responsibility to call the constructor of an abstract class if the abstract class cannot be instantiated?
Can interfaces have a constructor? How it is different than the abstract classes?
What is the need for interfaces?
What is polymorphic reference?
What is significance of a polymorphic reference, and how would you achieve the same?
If Object is a cosmic superclass, what is wrong if you refer every object by it?
Can we extend more than one class?
How do you achieve multiple inheritance in Java?
Can you implement more than one interfaces?
If your class implements two interfaces and both the interfaces declare similar methods, which method will be invoked? Is it permitted?
What is use of the final keyword?
Can we make the reference as final? What does it mean?
What is use of a static variable?
What is use of a static method?
Can we use a non-static method to process static variables?
Can we use a static method to process instance variables?
Can we declare static and instance variables with same name?
In what scenario can you use a static variable?
Can I apply static anywhere apart from variables?
What is the use of this keyword?
Explain the significance of the super keyword
Why the super keyword must be located as the first line of the constructor?
In what sequence the constructors will be called if we create an object of a subclass?
Do we have the destructors in Java?
Which methods are present in the Object class that can be overridden?
What is use of the toString() method?
What is the equals() method, and how is it used?
Can we declare an interface with the abstract keyword?
If an interface is internally a class, does it extend the cosmic super class, that is, the Object class by default?
What is the default method in an interface?
Why default method is required in an interface?
Can an interface have more than one method as default implemented methods?
What is a static method in an interface, and what is its significance?
What is a functional interface?
Which is a cosmic super class in Java?
What is the difference between an equal operator (= =) and equals method?
What is a var argument? Where can it be used?
What do you mean by method overloading?
What are the different rules for declaring the var argument method?
What is the difference between using the var argument and array as a method argument?
What is method overriding?
What are rules of method overriding in Java?
Can we overload a static method?
Can we override the static method?
What is a co-variant return type?
Can we change the return type of the overridden method?
Do we have any restrictions on the access modifier when we implement method overloading?
What is the difference between an abstract class and interface?
What is a marker interface?
What is use of a marker interface?
Can you list out some marker interfaces that you have worked with?
Can you create your own marker interface? How to declare it?
What is typecasting in Java, and which are the different types of typecasting available in Java?
Can you elaborate any situation where you can apply up-casting to objects or references?
What are the types of variables in Java? Also explain their scope.
What is an instance initializer block in Java?
What is difference between a static initializer block and instance initializer block in Java?
Can you explain the concept of wrapper classes in Java?
What is the significance of wrapper classes?
What is auto-boxing and auto un-boxing? In which scenario are they observed?
What is an immutable object? Can you list out some immutable objects that you have worked with?
What is the use of an immutable object? Why we should create such an object?
Can you create your own immutable object? How to create that?
What is an enum to you?
Can enum extend any other class?
Can we write an enum that implements an interface?
What is the connection of the toString() method with enum?
Can we declare constructors within enum?
Why the constructor of enum is kept as private?
Can we instantiate enum using the new keyword?
Explain some important methods of enum in Java
Packages
Which package is available as a default package for every Java class?
If you import the parent package, does the compiler automatically import sub-packages as well?
Can we have same classes in two packages of an application?
Explain the use of static import
Conclusion
4. Handling Exceptions
Introduction
Structure
Objective
What do you mean by handling an exception?
What is need for exception handling?
Explain hierarchy of an exception
Tell me something about the Throwable class
How do you classify exceptions?
Can you list out different exceptions that you know and the scenarios when they are thrown?
How to handle an exception?
Can you use the try block without the catch block?
Can we use a single try block to handle multiple types of exceptions?
Can a single catch block handle multiple types of exceptions?
What is a difference between error and exception in Java?
What is cascading of an exception?
What is a chained exception?
How do you handle the exception in a generic way?
When do you recommend of handling the exception in a generic way? What is the complexity of using this approach?
Can we use generic approach of exception handlers along with other exception handlers?
What is use of the finally block?
Can you use the finally block without using the catch block?
If we use the finally block without the catch block, what happens if the exception is thrown by the try block?
What is the difference between ClassNotFoundException and NoClassDefFoundError?
How to create a user-defined exception?
How to use a user-defined exception?
What is use of the throws keyword?
Give a scenario where the throws keyword can be used
What are the updates in exception handling provided by JDK 7?
What is automatic resource management?
How are the resources closed automatically in the automatic resource management concept in Java?
What is a multi-catch block statement?
In some cases, we observed the main method throws an exception. What do you mean by that?
What is the use of the printstackTrace() method?
Can we use the throw keyword for both the checked and unchecked exceptions?
Can we use the throws keyword for both the checked and unchecked exceptions?
What happens to the finally block if the try block returns a value to the caller? Does it still execute?
What happens if the try and finally blocks execute different Boolean values?
Is there any way by which you can avoid the execution of the finally block?
What is the reason for OutOfMemory Error? Do you have any ways to solve it?
If a method does not throws any checked exception, can we invoke such method in the try-catch block where the catch block handles the checked exception?
Conclusion
5. I/O and File Handling
Introduction
Structure
Objective
List different types of I/O streams
Explain hierarchy of byte-based classes
Explain System.in, System.out, and System.err
Explain hierarchy of character-based classes
What is the necessity of two types of streams? Why do we need byte streams and character streams?
In your opinion, which is better to use, byte streams or character streams?
What are filter streams, and which are those?
What is PrintStream and PrintWriter? Are they same? What is the difference between them?
Explain the File class?
What is FileInputStream?
What is FileOutputStream?
Can we read the data from webpage?
When is the Scanner class used?
What is a Buffered stream?
Explain BufferedWriter. Where are flush() and close() used?
Explain the hierarchy of data streams
Can we read the data from multiple sources at the same time?
How to create temporary files? How to delete temporary files?
Did you work with properties files? How to create properties files dynamically?
What is serialization and deserialization?
Which methods are declared within the Serializable interface?
Did you work with serialization and deserialization? Please explain the process
What is SerialVersionUID?
Sometimes, even if you implement Serializable for a class, you cannot serialize an object. Can you explain why?
How to customize the process of serialization?
How to protect the data from being serialized?
Have you dealt with Random access files?
If I want to create a directory, which class should I use?
Explain the difference between InputStream and OutputStream?
Can you explain the difference between BufferedReader and FileReader?
Explain the use of the PrintStream class?
Can we close the stream in a try block? Why one should close the streams in a finally block? What change happened in JDK 7 to close the stream?
Can we convert a file into a string? Can you explain how?
Can we set permissions on a file? Which permissions can be set on a file? How to set permissions on a file?
Have you ever got java.io.FileNotFoundException for Access is denied? Do you know how to fix that?
What is a memory-mapped file? Explain the advantages and disadvantages of a memory-mapped file
What is NIO? What is the difference between I/O and NIO?
What are the fundamental components of NIO?
What are selectors?
What are channels?
Explain the NIO channel classes
How and when the buffer is cleared when using the BufferedWriter class?
What is the output of the following code? Will the physical file will be available at the location after the execution of the following code?
How can you pull specific types of file for processing?
Conclusion
6. Concurrency
Introduction
Structure
Objective
What is multithreading? Can you explain multithreading?
What is a thread?
What are the advantages of multithreading?
What is a process? Can you differentiate between a process and a thread?
What is the difference between synchronous and asynchronous programming in multithreading?
Is it possible to predict the thread behavior?
What do you understand by inter-thread communication?
What is the purpose of the wait() method in a thread?
Are you aware of the synchronized block? Why the wait() method is called from the synchronized block?
How would you maintain the sequence of execution of a thread in Java? If you have multiple threads, how would you control that a particular thread executes first and other execute later?
What does the join() method do?
Explain the thread life cycle. What are the states in the lifecycle of a thread?
What is context switching?
Differentiate between the Thread class and Runnable interface for creating a thread?
What is the relationship between Thread and Runnable?
What are different overloaded constructors Thread provides?
Can we start a thread twice? What happens if the start() method is invoked twice on a thread?
Is it possible to invoke the run() method instead of start() directly?
Is it compulsory to override the run() method? What will happen if we do not override the run method?
Can we override the start() method? What will happen if we override it?
Why are the suspend() and resume() methods deprecated?
Why the destroy() method is deprecated?
Explain the difference between the wait() and sleep() method. What is the difference between the wait() and sleep() method?
How threads communicate with each other? Which methods the developer can use to achieve inter-thread communication?
Why wait(), notify(), and notifyAll() are in the Object class and not in the Thread class?
What is thread starvation?
Explain the daemon thread. What are daemon threads?
How to create a daemon thread? Can we make the user thread a daemon thread if the thread is started?
What is a shutdown hook?
When should we interrupt a thread?
What is synchronization? How to achieve synchronization?
Can you give any real-time example of synchronization in an application?
What is the purpose of the synchronized block?
Can we declare a constructor as synchronized?
Can you explain an intrinsic lock?
What is reentrant synchronization?
What is a deadlock?
How to detect a deadlock condition? How can it be avoided?
Explain the thread scheduler
What is the preemptive, non-preemptive scheduling and time slicing? Explain the advantages of preemptive, non-preemptive scheduling
What is thread priority?
What is race condition?
What is the volatile keyword in Java?
What is ThreadLocal?
What is a thread pool?
What is atomic action in concurrency in Java?
What is a lock interface in the concurrency API in Java?
Did you use concurrency APIs? Which concurrency APIs have you worked with? Which are the main components of a concurrency API?
What is the Executor interface in a concurrency API?
Explain the ExecutorService interface from the concurrency API
Explain the difference between the ScheduledExecutorService and ExecutorService interface?
What is the difference between Callable, Runnable, and Future interface?
What is the difference between traditional multithreading and parallel programming?
What is the ForkJoin framework in Java?
What is a divide-and-conquer algorithm in the fork-join framework?
State the ForkJoinPool features. Why is it necessary to explicitly shutdown the ForkJoinPool?
Can you explain the real-world application of the fork-join framework
What are the Executors in the Executor framework?
Explain FutureTask
What is difference between shutdownNow() and shutdown() in the Executor framework in Java?
How to terminate a thread in the Executor framework?
What are the different policies in the Executor framework?
How one can get a value returned from the Callable thread in the Executor framework?
Which classes in collection provide concurrency?
How can you solve the consumer–producer pattern by using BlockingQueue?
What care should be taken while writing a thread-safe code? What are the most important points one must keep in mind while writing a multithreaded application?
What happens when the object that has the lock calls the sleep() or wait() method?
Conclusion
7. Java Database Connectivity
Introduction
Structure
Objective
What is persistency?
What are the ways for persistency?
What is JDBC?
Can you explain the architecture of JDBC?
What is a driver in JDBC? Why it is required?
Why is a JDBC driver required? What is the use of the JDBC driver?
How many types of drivers are available? Which drivers have you worked with? What is a Type 4 driver?
Explain in detail types of drivers
Can you explain the procedure to connect to a DB? What are the steps to connect to a database?
What are the ways to register the driver?
Explain the difference between Class.forName() and DriverManager.registerDriver()
JDBC API
If JDBC is an API, who provides the implementation?
Can you list different interfaces of JDBC API?
What is the standard process to obtain a DB connection? How to obtain JDBC?
How to obtain a generated Primary Key (PK) from a DB?
How to use CallableStatement? How to call a procedure using CallableStatement?
What is ResultSet? How to obtain ResultSet?
What functionalities ResultSet provides? Which of the functionalities of ResultSet have you worked with?
How to find ResultSet has a data or it is empty?
What is scrollable ResultSet?
One can fire a query using the Statement instance, is it possible to insert a row to a DB without using statement or firing query?
If ResultSet is with a default working mechanism and one tries to update the data, what will happen?
Which kind of an exception would normally occur in JDBC, and how to handle it?
What is transaction management in JDBC?
What do you mean by ACID properties of transaction management?
Why the application needs transaction management?
Can you explain how transaction management increases the speed or performance of an application?
What are the types of transaction?
How to provide transaction management in JDBC?
What are commit() and rollback() methods?
What is Savepoint? How to use Savepoint?
What is metadata? What is DatabaseMetaData and ResultSetMetaData?
What is BatchUpdate? How to perform batch processing?
What is connected and disconnected architecture?
What is RowSet?
What are different types of RowSet?
RowSet is an interface. So, what are its types and implementation classes?
What is SQLTimeoutException?
Conclusion
8. Collections
Introduction
Structure
Objective
Explain the Collection framework. What is the Collection framework?
List the benefits of the Collections framework
Explain the difference between an array and collection. What are the main differences between an array and collection?
What are legacy classes?
What are the interfaces available in the collection framework? Explain the various interfaces used in the Collection framework
What is the advantage of the generic collection?
What is type erasure?
What is the difference between Collection and Collections?
What are the advantages of the Collection framework?
State the difference between ArrayList and Vector
What are the similarities between ArrayList and Vector?
What is the difference between ArrayList and LinkedList?
What are the differences between Array and ArrayList?
Explain the difference between the length of an array and size of ArrayList?
Can array and ArrayList be inter-convertible? How to convert ArrayList to an array and an array to ArrayList?
How would you create an array of primitives from a list?
ArrayList can be modified at runtime. What if we want a read-only ArrayList?
Can ArrayList contain duplicate elements? What are the ways to remove duplicates from ArrayList?
By default, ArrayList is ordered. Is there any way by which you can reverse or sort the elements in ArrayList?
What are the ways to synchronize ArrayList?
Explain the difference between the List and Set interfaces
What is the difference between HashSet and TreeSet?
What is the difference between HashMap and HashTable?
Does HashTable allow null? Can you explain the reason why HashTable does not allow null? Can you explain the reason why HashMap allows null?
What is WeakHashMap?
Can you explain the concept of WeakHashMap with the help of some code?
Explain the differences between Iterator and ListIterator?
State the differences between Iterator and Enumeration?
Explain the difference between the List and Set interfaces?
Explain the differences between the Set and Map interfaces?
What are the differences between HashMap and HashSet?
Explain the differences between HashMap and TreeMap?
It is often said that HashMap is sorted by keys. How can you sort it by values?
What are the differences between HashMap and Hashtable?
What does Comparable do?
Set allows only unique elements; then, why are we getting the size equal to three and not two? What do we need to do so that Set will only have unique elements?
Why are we getting an exception? What to do to get rid of the exception?
What is the difference between Comparable and Comparator?
What do you understand by BlockingQueue?
Why to use Properties file?
What does the hashCode() method do? Explain the hashcode() method?
What will be the output of the following code?
The instance of an employee exists in the set; then, why the initial and final size is same? What to do so that the code will work fine?
Why do we override the equals() method?
What will be the output of the following code?
Though the instance is available, why the employee instance is not getting eliminated? What do we need to do so that the remove method will work?
Can we synchronize the collection interfaces? What are the ways by which one can synchronize the List, Set, and Map elements?
What is hash-collision in the hashtable, and how to handle it?
Explain the purpose of the initial capacity and load factor parameters of a HashMap? What are their default values?
What is the default size of load factor in any collection on which hashing is based? How is it calculated?
What is the meaning of fail-fast?
Explain the differences between fail-fast and fail-safe?
Which features are added to collection in JDK 8? What are the Collection-related features in Java 8?
Explain why Collection does not extend the Cloneable and Serializable interfaces?
Why the Map interface does not extend the Collection interface?
Explain an Iterator. What is an Iterator?
Why Iterator does not offer a method for adding elements to the collection?
Can we directly use the next() method to fetch the element without moving the cursor using the Iterator? Why the Iterator does not offer a method to get the next element directly without moving the cursor?
State the differences between the Iterator and ListIterator?
What are different ways available to iterate over a list?
What is UnsupportedOperationException? When does the UnsupportedException occur in the execution?
What is the difference between the following two statements
How HashMap works in Java?
Can we use instance of any class as Map key?
How one can visit each entry in the collection of type Map? What are different Collection views provided by the Map interface?
Which collection classes from the framework are thread-safe?
Can you explain more about CopyOnWriteArraySet?
What is Queue and Stack, list their differences?
What are the best practices related to the Java Collections framework?
Can a null element be added to TreeSet or HashSet?
What are the differences between Collection and Collections?
What are the additional features provided by NavigableSet than SortedSet?
What is PriorityQueue, and how it works?
How PriorityQueue is different than TreeSet or TreeMap if it uses the same Comparator and Comparable interfaces for sorting?
What is Dequeue? Can you explain its working?
Out of different Queue implementations, how do you decide which to use?
What is IdentityHashMap? How is it different than normal HashMap?
Which are the most common methods from the Collections class that can be used to perform operations on List?
Conclusion
9. Miscellaneous
Introduction
Structure
Objective
Are the following two same or different?
Are the preceding to statements same or different?
What are the differences between StringBuffer and StringBuilder?
What are the differences between StringBuffer and String?
What do you mean by reflection?
Can you explain how to use reflection?
How to get an object of a class without using the new operator?
List out the different methods of reflection API with their usage
Can we access the private field of another class using reflection?
What is an Inner class and their types?
What is the need for inner classes, or why do we use inner classes?
Can a static nested class have access to any other members from an enclosing class?
Can an inner class be declared as private?
What is shadowing?
What is JUnit?
What is unit testing?
Can you explain how do you test a unit of your application?
What are the useful JUnit extensions?
What are the important JUnit annotations?
What is use of @Before and @After annotations?
What is use of the JUnitCore class?
What is the difference between manual testing and automated testing?
How is the testing of “private” method done?
What are the methods in fixtures?
What is internationalization?
What is localization?
How to change the format of a number using the Locale class?
Conclusion
10. Functional Programming
Introduction
Structure
Objective
What are the new features introduced in Java 8?
What are functional interfaces, and how to create them? Is it necessary to declare a functional interface by the @FunctionInterface annotation?
Do we have any functional interfaces prior to Java 8 as well?
What is an SAM Interface?
Which guidelines are to be followed while defining a functional interface?
What are the default methods?
What are the different characteristics of the lambda function?
Can you explain the different parts of a lambda expression, or how to write a lambda expression?
Can you show how can you implement a lambda expression by some real code?
Did you work with Collection? Did you use the Stream API? Can you explain us the difference between the Collection API and Stream API?
What is method reference?
Explain the meaning of String::valueOf
What is a Stream API? Why do we require the Stream API?
What is the difference between limit() and skip()?
Write a program to print 5 random numbers using forEach in Java 8?
What are intermediate and terminal operations? What is the difference between intermediate and terminal operations in Stream?
Can you explain about the reduce operation in Stream?
What is stream pipelining?
What is meant by Stream is lazy?
Please list and explain different intermediate and terminal operations
What is the difference between the findFirst() and findAny() method? Can you explain the difference between the findFirst() and findAny() method
Can you show how the streams are lazy?
What is the difference between Iterator and Spliterator?
Explain an Optional class?
How can we avoid NullPointerException while performing operations on an object?
What is a predicate? Explain the difference between a predicate and function?
What is the Consumer functional interface?
What is the Supplier functional interface?
What does the map() function do? Why do you use it?
What does the flatmap() function do? Why do you need it?
Explain the difference between map() and flatMap()?
What does the filter() method do? When to use it?
Why to use the peek() function? What does the peek() method do? When should you use it?
What are the ways to create a Stream? Can you convert an array to Stream? How?
Can you create a stream for primitives? What are its different types?
Can you re-use the stream once the terminal operation is invoked? Can you give any real-time example?
Is there any way to re-use the stream after the terminal operation?
Can you explain how would you use streams to collect the object of Students, whose name starts with an “S”?
Can you explain Stateless and Stateful operations in Java streams?
What is the parallel stream?
Can you explain how to create a parallel stream?
Can we define the number of threads to generate parallel streams?
Conclusion
11. Design Patterns
Introduction
Structure
Objective
Can you tell us what a design pattern is?
What are the different categories of Java design patterns?
Explain the advantages of the Java design pattern?
Explain the disadvantages of design patterns?
Which design pattern can be used to sequentially access the elements of a collection object easily?
When is the service locator pattern used?
Which technologies use the Service Locator pattern?
Which pattern can be used to decouple an abstraction from its implementation in the code?
Which design pattern will be helpful when one wants to add a new functionality to an existing object?
Which design pattern is useful in case of passing data with multiple attributes from the client to the server in one shot?
When to use the intercepting pattern?
What is a factory design pattern? When can the factory pattern be used? What are the benefits of the factory design pattern?
Why to use a factory class to instantiate a class when we can use a new operator?
Can you give some examples of the factory design pattern implementation in JDK?
What is an abstract factory pattern?
Differentiate between the factory and abstract factory design pattern?
Explain the singleton pattern?
How to implement the singleton pattern?
What are the limitations and disadvantages of the singleton Pattern?
Can you give some examples of implementation of the singleton design pattern by JDK?
Can you write thread-safe singleton? Why do we need that?
Can we create a clone of a singleton object?
Is it better to make the whole getInstance() method synchronized, or will it be better to synchronize only the critical section? Which one will you prefer?
Can you name a few design patterns used in the standard JDK library?
What are the adapter patterns?
Explain the decorator pattern. Give some examples from JDK which implements Decorator Design pattern
When to use the template method design pattern in Java?
Differentiate between the strategy and state design pattern in Java?
What is a proxy design pattern?
Explain the difference between the decorator and proxy pattern
State the difference between proxy and adapter?
Explain the difference between factory and abstract factory
When to use the strategy design pattern in Java?
State the advantages of the composite design pattern in Java?
Explain the uses of the composite pattern? When to use the composite design pattern in Java? Have you used it previously in your project?
What is the observer design pattern in Java? When do you use the observer design pattern in Java?
Can you give any typical example of the observer design pattern?
What is the builder design pattern in Java? When do you use the builder design pattern? What problems does the builder design pattern solve? State the advantages of the builder design pattern
Give the examples from JDK that implements the builder design pattern
What is the proxy pattern? What does it do? What are the types of proxies? What are the use cases of the proxy pattern?
Explain the chain of responsibility pattern and its advantages
How is the bridge pattern different from the adapter pattern?
Under which scenarios can one can the adapter pattern?
Explain the dependency injection and service locator patterns. Also state their differences
When to use the setter and constructor injection in the dependency injection pattern?
What is the MVC pattern?
Explain the intercepting filter design pattern along with its benefits?
Explain the data access object or DAO pattern?
What is a front controller design pattern? Can you give an example of a front controller?
Which design pattern will you use to create a complex object?
What is the null object pattern?
What is the open–closed design principle?
What are the SOLID design principles? Can you give an example of the SOLID design principles?
Conclusion
12. The Basics of Web
Introduction
Structure
Objective
What are types of enterprise architecture? Which architectures have you worked with?
Single-tier architecture
Two-tier architecture
Three-tier architecture
N-tier architecture
What is role of containers in Java EE?
Explain different types of containers
Which are different application developments and deployment roles?
What is the process of deploying application?
What are protocols? Which protocols have you worked with?
Can you explain different Http methods?
What is status code?
Can you explain the components of the Web application?
Can you explain the MVC 1 and MVC 2 architecture?
What is a Servlet and its use?
Explain the Servlet life cycle
Did you develop a Servlet-based application? Explain the steps to develop a Servlet application. Explain the ways to configure Servlets?
How to read request parameters?
What is the difference between the getRequestDispatcher() method of ServletRequest and ServletContext?
How to define the custom init() method?
Differentiate between the GET and POST method?
How a client can send the information to a server?
What is the difference between attribute and parameters?
What are headers and different types of headers?
What is a scope? What are the different types of scopes?
Explain the difference between ServletConfig and ServletContext
What is session tracking? What are ways of session tracking? Why session tracking is required? When to use session tracking?
How to work with the HttpSession object in a Servlet?
What is event handling in a Servlet?
What is JSP? Why to use JSP? How JSP is useful in Web programming?
What are the advantages of JSP?
Explain the life cycle of JSP?
What are implicit objects in JSP?
What do you mean by action tag? How can you use it?
What is the difference between include directive and include standard action?
What is EL and EL function?
Explain JSTL
How to create a custom tag in JSP?
What are filters? When to use filters? How to configure filters?
Conclusion
13. Spring and Spring Boot
Introduction
Structure
Objective
Tell me something about the Spring framework?
So many times we seen the blogs, books, or references claiming that the Spring framework makes the development easy. Can you explain how?
What do you mean by boiler-plated code?
Can you provide some examples of boilerplate codes?
How many modules of Spring you have used?
What is DI in Spring?
Please explain a dependency injection
Explain dependency injection with a relevant example
Is DriverManagerDataSource the only implementation provided by the framework?
Consider a scenario in which multiple requests for obtaining connections are fired. Will it be feasible to use DriverManagerDataSource?
What is IoC/inversion of controller?
Please explain about Spring IoC container
What is a bean according to you? Or, explain bean with reference to the Spring framework
You just mentioned about the ApplicationContext interface. If it is an interface, do we need to provide its implementation?
Can you tell us an overall process to use ClassPathXmlApplicationContext?
Can we use a different file name for the bean configuration? Or, is it mandatory to use beans.xml as the file name?
Is the location of the beans.xml file fixed? Can we change the location of the file?
Can we use more than one configuration file? Is it possible to distribute the beans in more than one configuration file in a single application?
What are the ways to get the container instantiation for more than one bean configuration files? How to load more than one bean configuration file while creating the container?
Please write a standard way of configuring bean in an XML file
What is the way to configure a bean having has-a-kind relation?
You just mentioned a couple of bean configurations; I would like to know how many instances the container will create for such a bean configuration?
Does that mean the developer gets only one instance to work with from the container?
What is the default scope of a bean?
You just said beans are singleton. Can we change the default singleton scope?
Is it possible to define the bean scopes using annotations?
Is it possible to create user-defined scopes?
When does the instantiation process take place by the container? Whether the bean is initialized eagerly or lazily?
Is it possible to change the default mechanism of bean instantiation?
Can a bean be initialized lazily? Is it possible to control lazy initialization at the controller layer?
In your opinion, which initialization is desired, eager or lazy, and why?
What is auto-wiring? Can we use auto-wiring for primary dependencies?
What are the types of auto-wiring, and how to configure them?
Explain the bean life cycle
Is it possible to set some mechanism to modify the bean properties after its instantiation?
Using init-method as an attribute and the InitializingBean interface are two ways for modifying the bean properties after instantiation. Which one is preferable?
Can we have custom cleanup methods?
Providing each time init-method or destroy-method in every individual bean configuration is repetitive as well as time-consuming. Can we have an alternative way to provide default initialization or destroy method?
ApplicationContextAware, BeanFactoryAware, or BeanNameAware are used for?
What is the parent attribute in the bean configuration used for?
XML and annotation based are two different ways of configuration; which one do you prefer?
Are the annotations by default enabled?
Both <context:annotation-config> and <context:component-scan>, which are written on the top of our XML file, activate annotation-based configurations. Are they same? Or, are they different?
Which annotation activates package scanning for annotation?
Explain stereotype annotation?
Which are the stereotype annotations? Explain different stereotype annotations in Spring
Explain @Configuration
Explain @Bean configuration
Why to use @Autowired? Explain the @Autowired annotation
When to use the @Qualifier annotation? What does the @Qualifier annotation signify?
What does the @Required annotation signify?
Are @Autowired and @Required same? Which one is recommended to use?
Why to use the @Scope annotation?
Can you explain some features of Spring MVC framework?
Explain Spring MVC framework
Please explain the components of the Spring MVC design pattern
Which annotations have you worked with while dealing with the Spring MVC framework?
How does the front controller the controller to delegate the request?
You just told the request mapping is available in WEB-INF/ servlet_name-servlet.xml file. Is this location fixed? Can we change the location or name of the file?
Did you configure <load-on-startup>1</load-on-startup>?
What <load-on-startup>1</load-on-startup> does?
Which are the different beans contained within WebApplicationContext?
Did you work with message resource bundle? What is its use?
Did you work with validation? What are the ways of providing validation? Why do we need validation?
What is AOP?
Under which circumstances will you prefer AOP? What are the use cases to choose AOP? Can you explain the situations to refer AOP?
Explain the concepts of AOP
What is an advice, and what type of advice are available?
In what ways weaving can be done? Which types of weaving are supported by Spring AOP?
Explain how to write the pointcut expression using a couple of examples. Can you write pointcut expression to track all the methods from the package com.dao?
Explain the pointcut designators you have used, or explain the pointcut designators you know
Can you explain Around advice?
Did you work with Spring Boot? Explain Spring Boot. What is Spring boot?
Can you tell us some features of Spring Boot?
Did you work with Spring Boot projects? Which starters you worked with?
There are many ways to create Spring Boot applications. How many have you worked with? Can you tell us the ways of creating a Spring Boot project?
Which annotations have you worked for creating REST applications?
Can you explain about the @PutMapping and @PatchMapping annotations?
Which are the annotations to map handler methods?
What are runners in Boot?
How you can read the input from a request? Which annotations have you used to read request input?
What is the difference between @RequestParam and @QueryParam?
Did you work with Spring Boot’s internal database?
How to execute database schemas to create a table or insert records in table?
What is the use of RestTemplate? How to use RestTemplate?
What is HATEAOS?
How to provide HATEAOS support in an application?
What is Swagger, and why to use it?
Conclusion
14. Hibernate
Introduction
Structure
Objective
What is ORM?
Which are the different frameworks that support ORM?
What are the features of ORM? How ORM helps developers?
Are there any drawbacks of ORM or Hibernate?
Explain the architecture of Hibernate?
What is Hibernate? Are JPA and hibernate same or different?
Explain the interfaces or core components you worked with in Hibernate
In how many ways a class can be mapped to table/tables? How hibernate does mapping of object to the table?
Which files are needed to maintain the configuration in Hibernate?
Can we change the name of the hibernate.cfg.xml file?
How to obtain SessionFactory?
How many SessionFactory objects are usually created and can be used by a developer in an application?
Can we communicate with two different databases in an application using Hibernate? How to create two session factories in Hibernate?
Is SessionFactory a thread-safe object?
Is Session a thread-safe object?
Please explain the phases of an entity. What is a detached entity? What are the states of an object?
How to map a class to a table? Explain the annotations to map an entity to a row in table
What does the @Id annotation do?
What does @NaturalId do?
Can you give any real-time example of @Id and @NaturalId?
Is it possible to stop a data member from being persisted or ignore fields to save in the database?
What methods are provided by Session?
Explain the difference between persist() and save() of the Session interface?
Explain the differences between the save(), saveOrUpdate(), and persist() method of Hibernate. Which one should we use?
What will be the output of the following code?
What is a difference between the get() and load() method?
Do you know generator classes? How many generator classes have you worked with? Please explain generator classes in Hibernate
What does hibernate.hbm2ddl.auto mean?
What does hibernate.dialect do?
List the different mapping strategies to implement inheritance in Hibernate
How to map the Table Per Class Hierarchy, Table Per Concrete Class, and Table Per Subclass?
Can you explain the advantages and disadvantages for inheritance mapping strategies?
What are the different association models available in Hibernate?
Can you explain how to configure the many-to-one association with a relevant example?
Can you explain what is a many-to-many association, and how can you configure that with some real-time example?
What is unidirectional and bidirectional mapping?
One of the attribute of entity needs to be calculated by some expression. How can you map such attribute using Hibernate?
What is lazy and eager fetching?
What is cascading? What is CASCADE.ALL means? Which of the cascading options you worked with?
How to map java.util.Date in Hibernate?
How can you map enum to database using the Hibernate framework?
What is a transaction? How to manage a transaction in Hibernate?
What is HQL?
What are the advantages of HQL?
Explain the disadvantages of HQL
What is caching? Why caching is used?
Explain caching in Hibernate
Explain the difference between the first- and second-level cache. Or the first-level cache versus second-level cache in Hibernate
What is the similarity between cache and lazy loading?
What is an immutable class in Hibernate? How to make an immutable class in Hibernate?
Immutability specifies the object cannot be mutated, but sometimes, the object needs to be updated in the DB. How to change the data?
What is Automatic Dirty checking in Hibernate?
What is an inspection strategy?
What is the use of the @NamedQuery annotation?
Conclusion
Index

Loading...