Wednesday, June 22, 2022

How To Prepare For Java Interview For 5 Years Experience

Don't Miss

What Is The Difference Between Execute Executequery Executeupdate

Java Interview Preparation for 2 Years Experienced | java Coding interview questions

Statement execute is used to execute any SQL query and it returns TRUE if the result is an ResultSet such as running Select queries. The output is FALSE when there is no ResultSet object such as running Insert or Update queries. We can use getResultSet to get the ResultSet and getUpdateCount method to retrieve the update count.

Statement executeQuery is used to execute Select queries and returns the ResultSet. ResultSet returned is never null even if there are no records matching the query. When executing select queries we should use executeQuery method so that if someone tries to execute insert/update statement it will throw java.sql.SQLException with message executeQuery method can not be used for update.

Statement executeUpdate is used to execute Insert/Update/Delete statements or DDL statements that returns nothing. The output is int and equals to the row count for SQL Data Manipulation Language statements. For DDL statements, the output is 0.

You should use execute method only when you are not sure about the type of statement else use executeQuery or executeUpdate method.

Arraylist Linkedlist And Vector Are All Implementations Of The List Interface Which Of Them Is Most Efficient For Adding And Removing Elements From The List Explain Your Answer Including Any Other Alternatives You May Be Aware Of

Of the three, LinkedList is generally going to give you the best performance. Heres why:

ArrayList and Vector each use an array to store the elements of the list. As a result, when an element is inserted into the middle of the list, the elements that follow must all be shifted accordingly. Vector is synchronized, so if a thread-safe implementation is not needed, it is recommended to use ArrayList rather than Vector.

LinkedList, on the other hand, is implemented using a doubly linked list. As a result, an inserting or removing an element only requires updating the links that immediately precede and follow the element being inserted or removed.

However, it is worth noting that if performance is that critical, its better to just use an array and manage it yourself, or use one of the high performance 3rd party packages such as Trove or HPPC.

Senior Java Interview Questions And Answers

A Guide to conquer your next Senior Java Developer Interview

Technical Interviews are always nerve-wracking, especially when you have high expectations of getting into your dream workplace. However, with the proper guidance and preparation, there is a high possibility of conquering your next senior Java interview.

This article will guide you toward preparing for your next senior Java developer interview to achieve top results.

Choose a job you love, and you will never have to work a day in your life Quote by Confucius

The senior Java developer role might call in slightly different terms such as Senior Java Application Developer, Senior Java Backend Developer, Senior Software Engineer Java.

However, with my industry experiences, I can identify four main evaluation categories during an interview. They are

  • Problem Solving Skills

  • Technical Experience

  • Attitude and Team Skills

  • Lets look deep into these categories and answer some of the common questions in these interviews.

    Also Check: Best Interview Attire For A Woman

    What Is Aggregation In Java

    The case of Aggregation is Student in School class when School shut, Student despite everything exists and afterwards can join another School or something like that. In UML documentation, a structure is signified by a filled precious stone, while conglomeration is indicated by an unfilled jewel, which shows their undeniable distinction regarding the quality of the relationship.

    Q12 What Are The Important Methods Of Java Exception Class

    TCS

    Exception and all of its subclasses doesnt provide any specific methods and all of the methods are defined in the base class Throwable.

  • String getMessage This method returns the message String of Throwable and the message can be provided while creating the exception through its constructor.
  • String getLocalizedMessage This method is provided so that subclasses can override it to provide locale specific message to the calling program. Throwable class implementation of this method simply use getMessage method to return the exception message.
  • Synchronized Throwable getCause This method returns the cause of the exception or null id the cause is unknown.
  • String toString This method returns the information about Throwable in String format, the returned String contains the name of Throwable class and localized message.
  • void printStackTrace This method prints the stack trace information to the standard error stream, this method is overloaded and we can pass PrintStream or PrintWriter as an argument to write the stack trace information to the file or stream.
  • Read Also: Questions To Ask A Cfo

    What Are The Important Benefits Of Using Hibernate Framework

    Some of the important benefits of using hibernate framework are:

  • Hibernate eliminates all the boiler-plate code that comes with JDBC and takes care of managing resources, so we can focus on business logic.
  • Hibernate framework provides support for XML as well as JPA annotations, that makes our code implementation independent.
  • Hibernate provides a powerful query language that is similar to SQL. However, HQL is fully object-oriented and understands concepts like inheritance, polymorphism, and association.
  • Hibernate is an open source project from Red Hat Community and used worldwide. This makes it a better choice than others because learning curve is small and there are tons of online documentation and help is easily available in forums.
  • Hibernate is easy to integrate with other Java EE frameworks, its so popular that Spring Framework provides built-in support for integrating hibernate with Spring applications.
  • Hibernate supports lazy initialization using proxy objects and perform actual database queries only when its required.
  • Hibernate cache helps us in getting better performance.
  • For database vendor specific feature, hibernate is suitable because we can also execute native sql queries.
  • Overall hibernate is the best choice in current market for ORM tool, it contains all the features that you will ever need in an ORM tool.

    What Is An Instance Variable In Java

    Instance variable in Java is used by Objects to store their states. Variables that are defined without the STATIC keyword and are Outside any method declaration are Object-specific and are known as instance variables. They are called so because their values are instance specific and are not shared among instances.

    Don’t Miss: Interview Attire Womens

    What Is A Join And Explain Different Types Of Joins

    Joins are used in queries to explain how different tables are related. Joins also let you select data from a table depending upon data from another table.

    Types of joins:

    INNER JOINs,OUTER JOINs,CROSS JOINs

    OUTER JOINs are further classified as

    LEFT OUTER JOINS,RIGHT OUTER JOINS andFULL OUTER JOINS.

    For more information see pages from books online titled: “Join Fundamentals” and “Using Joins“.

    Java 8 Interview Questions

    Java Interview Preparation for 3 Years Experienced

    You can further see Iterator vs Enumeration in Java for more differences between both of them. What is the Difference between fail-safe and fail-fast Iterator in Java? See Difference between fail-safe and fail-fast Iterator in Java for the answer of this Java collection question. How HashMap works internally in Java? One of the most frequently asked Java interview question to experience Java programmer of 4 to 5 years of experience.

    Don’t Miss: System Design Interview Preparation

    What Is Public Static Void Main In Java

    This is the access modifier of the main method. It has to be public so that java runtime can execute this method. Remember that if you make any method non-public then its not allowed to be executed by any program, there are some access restrictions applied. So it means that the main method has to be public. Lets see what happens if we define the main method as non-public. When java runtime starts, there is no object of the class present. Thats why the main method has to be static so that JVM can load the class into memory and call the main method. If the main method wont be static, JVM would not be able to call it because there is no object of the class is present.

    Java programming mandates that every method provide the return type. Java main method doesnt return anything, thats why its return type is void. This has been done to keep things simple because once the main method is finished executing, java program terminates. So there is no point in returning anything, there is nothing that can be done for the returned object by JVM. If we try to return something from the main method, it will give compilation error as an unexpected return value.

    Java Developer Interview Questions In Stockholm Sweden

    “Junior developers are often responsible for writing the more monotonous and simple code required by senior members of the development team. Because of this, interviews will be designed to test your knowledge of the fundamentals of Java so be prepared to answer technical questions that you likely came across in college. Data structures and algorithms will be heavily emphasised. A bachelor’s degree or equivalent work experience is required. “

    java developer interview questions shared by candidates

    Read Also: Interview Questions To Ask A Cfo

    What Is The Benefit Of A Multi

    Multi-catch block is an improvement that came with the Java 7 release. Be ready to answer questions on this critical part of the programming language.

    Example answer:”With multi-catch blocks, code is shorter. This makes code easier to create and easier for others to interpret. Also, making exception parameters final is less complex with this format.”

    What Is Meant By Composition

    Selected

    This is definitely one of the most important Java interview questions. Holding a class’s reference within any other class is called composition. When any object contains another object, in case it is not possible for the contained object to exist without the container object’s existence, then it is known as composition. Put simply it can be asserted that composition happens to be a case of aggregation representing a stronger connection between 2 objects. An example is a class consisting of students. It is not possible for a student to exist sans a class. A composition is present between students and class.

    Read Also: Design Interview Preparation

    What Is Class In Java

    In the real world, you often have many objects of the same kind. For example, your bicycle is just one of many bicycles in the world. Using object-oriented terminology, we say that your bicycle object is an instance of the class of objects known as bicycles. Bicycles have some state and behaviour in common. However, each bicycles state is independent of and can be different from that of other bicycles. When building bicycles, manufacturers take advantage of the fact that bicycles share characteristics, building many bicycles from the same blueprint. It would be very inefficient to produce a new blueprint for every individual bicycle manufactured. In object-oriented software, its also possible to have many objects of the same kind that share characteristics: rectangles, employee records, video clips, and so on. Like the bicycle manufacturers, you can take advantage of the fact that objects of the same kind are similar and you can create a blueprint for those objects. A software blueprint for objects is called a class .

    Why Do You Need Indexing Where Is Stored And What Do You Mean By Schema Object For What Purpose We Are Using View

    We cant create an Index on an Index… The index is stored in the user_index table. Every object that has been created on Schema is Schema Object like Table, View etc. If we want to share the particular data to various users we have to use the virtual table for the Base table. So that is a view.

    Indexing is used for faster search or to retrieve data faster from the various tables. Schema containing a set of tables, basically schema means logical separation of the database. The view is crated for faster retrieval of data. Its a customized virtual table. we can create a single view of multiple tables. Only the drawback is..view needs to be get refreshed for retrieving updated data.

    You May Like: Prepare For System Design Interview

    Java Interview Questions On Concurrency

    2.1. What is Thread Safety?

    Defining thread safety is surprisingly tricky. At the heart of any reasonable definition of thread safety is the concept of correctness. So, before understanding the thread-safety we should understand first, this correctness.

    In this must-read Java tutorial, clear your doubts and be ready to answer some popular interview questions. e.g.

    • What is correctness in thread safety?
    • Give an example of thread-safe class?
    • How you will design a thread safe Java class?
    • Are immutable classes thread safe?

    2.2. Object level locking vs. class level locking

    At the heart of concurrency, there lie the concepts of object locking. Locking happens at instance level as well as class level.

    • Object level locking is mechanism when you want to synchronize a non-static method or non-static code block such that only one thread will be able to execute the code block on given instance of the class. This should always be done to make instance level data thread safe.
    • Class level locking prevents multiple threads to enter in a synchronized block in any of all available instances on runtime. This means if in runtime there are 100 instances of DemoClass, then only one thread will be able to execute demoMethod in any one of the instances at a time, and all other instances will be locked for other threads. This should always be done to make static data thread safe.

    Understand the whole concept in detail in this tutorial.

    Also, it will help you in answering basic questions such as

    How Will You Use Jsp El In Order To Get The Http Method Name

    How to prepare Java interview for Experienced

    Using pageContext JSP EL implicit object you can get the request object reference and make use of the dot operator to retrieve the HTTP method name in the JSP page. The JSP EL code for this purpose will look like $.

    In case you are facing any challenges with these java interview questions, please comment on your problems in the section below. Apart from this Java Interview Questions Blog, if you want to get trained from professionals on this technology, you can opt for structured training from edureka!

    Read Also: Mailscoop Io

    What Is Generics In Java

    Generics enable types to be parameters when defining classes, interfaces and methods. Much like the more familiar formal parameters used in method declarations, type parameters provide a way for you to re-use the same code with different inputs. The difference is that the inputs to formal parameters are values, while the inputs to type parameters are types.

    What Is Difference Between Javascript And Java

    Some of the key differences between JavaScript and Java are:

    • Java is Object Oriented Programming Language. But, JavaScript is an Object Oriented Scripting language.
    • Java code runs in a virtual machine or browser where JavaScript code runs on browser.
    • We have to compile Java source code to byte code before JVM can understand and execute it. JavaScript code is text based and we dont need to compile it.
    • We use JavaScript to perform browser specific tasks. We use Java to create standalone utility apps, web applications, and web services.
    • JavaScript is lightweight whereas we have to install Java and configure it to run.

    You May Like: Questions To Ask The Cfo In An Interview

    What Is Garbage Collection In Java

    Garbage collection is the process of identifying used and unused objects on java heap and removing unused object from the heap.A live object means an object is still being referred to some part of program. Unused object means object is not being referred by any part of program and is eligible for garbage collection.Programmer does not have to do manual garbage collection like C or C++. Java takes care of

    Can We Use Hashmap In A Multi

    Java Developer Interview Questions For 5 Years Experience ...

    You can use the HashMap but the probability of working fine depends on the way we use it. For instance, consider the HashMap of configuration properties, if the HashMap initialization was done by using just one thread, and the remaining threads do the task of reading from the map, then HashMap would work perfectly well.

    The problem arises when there is at least one thread that updates the Map by means of adding, updating, or deleting the map content. The put method of the map resizes the map that can cause a deadlock or infinite loop while the threads operate. Hence, during such scenarios, we can use the HashTable or ConcurrentHashMap.

    You May Like: Interview With Cfo

    If You Were Training Someone In Java What Would You Tell Them About Wrapper Classes

    Give an accurate answer that shows your technical knowledge of Java and also your interpersonal skills and ability to share information with others.

    Example answer:”If I were training someone in wrapper classes, I would first make sure they understood all eight primitive types and how they can use them. I think the most important thing to convey is that assigning a wrapper class is final and immutable. Knowing this will save that person a lot of time.”

    Related:6 Qualities That Make a Great Team Player

    What Is The Result Of The Below Code And Why

    publicclassTestClasspublicstaticvoidsomeMethodpublicstaticvoidsomeMethod}

    The output of this code is String method Invoked. We know that null is a value that can be assigned to any kind of object reference type in Java. It is not an object in Java. Secondly, the Java compiler chooses the method with the most specific parameters in method overloading. this means that since the String class is more specific, the method with String input parameter is called.

    Recommended Reading: Questions To Ask Cfo During Interview

    Describe The More Commonly Found Functional Interfaces In The Standard Library

    Although many functional interfaces exist, these are the one’s users most likely encounter:

    • Function. Takes one argument and returns a result
    • Consumer. Takes one argument and returns no result
    • Supplier. Takes a not argument and returns a result
    • Predicate. Takes one argument and returns a boolean
    • BiFunction. Takes two arguments and returns a result
    • BinaryOperator. Its like a BiFunction, except it takes two arguments and returns a result, and they are all the same type
    • UnaryOperator. Its like a Function, but it takes a single argument and returns a result of the same type

    More articles

    Popular Articles