Thank you for sharing...Share on Facebook7Share on Google+1Pin on Pinterest0Tweet about this on Twitter


Java language official logoJava interview usually consists of two parts. In the first part, classical interview questions are asked as the interviewers try to get basic understanding of you and your personality. However, in the second part you can expect purely targeted java interview questions.

It is better to prepare for them in advance, and that’s why we list here a list of fifteen most common java interview questions. Java is very broad field, that’s why the variety of questions you can get is huge. But the key to succeed in the interview is to not be too nervous and do not let the huge amount of questions you can get to get on you. Just have a look at a list of 15 common java interview questions that follows. If you know the answers to them and understand what it is about, you are fine with your java skills and preparation for an interview! Good luck!

 

Most common java interview questions

  • Question: Can you define an Iterator?
    Answer: Several from the collection classes provide traversal of their contents using a java.util.Iterator interface. This particular interface enables you to walk-through a collection of objects, operating on every object in turn. Keep in mind whenever using Iterators that these include a snapshot of the collection at the moment the Iterator has been obtained. That’s why typically it isn’t recommended to modify the particular collection itself while traversing an Iterator.
  • Question: Can you say what is the reason for garbage collection in Java, and in which situation is it used?
    Answer: The reason for garbage collection is usually to recognize and discard objects which are not anymore needed by a program, so their resources can be reclaimed and also used again. Any Java object will be subject to garbage collection any time it becomes inaccessible to the program within that it is used.
  • Question: Can you identify the 1st argument of the String array in main method?
    Answer: The String array is actually empty. It doesn’t have any kind of element. It is different for example in comparison to C/C++, where the first element will be the program name by default.
  • Question: Do you know what is the catch or declare rule for method declarations?
    Answer: Whenever the checked exception might be thrown within  body of the method, the method have to possibly catch this exception or declare this exception in its throws clause.

How it look in a mind of a java programmer

Other common java interview questions

  • Question: Can you name the main difference between preemptive scheduling and time slicing?
    Answer: When preemptive scheduling is set, the highest priority process executes till it gets into the waiting or dead states or till the higher priority process starts to exist. Oppositely, when time slicing is set, any process executes for the predetermined slice of time after which reenters the pool of ready tasks. The scheduler after that decides about the task that should execute next, depending on priority along with other factors.
  • Question: Can you define runtime exceptions?
    Answer: Runtime exception is an exception which is thrown at runtime as a reason of either wrong input data or wrong programm logic etc. Runtime exceptions are never checked by the compiler at compile time.
  • Question: Can you say what is the difference between defining the variable and declaring the variable?
    Answer: When you declarate a variable, you simply mention the type of the variable and the name of it. You do not initialize it. But whenever defining a variable, you have to declare it and also carry out the initialization.
    For example String t,  is purely a declaration, while String t = new String (“rtfd”) is the definition.
  • Question: Can you explain various ways of using thread in Java?
    Answer: The thread may be implemented using runnable interface or simply by inheriting from the predefined Thread class. The fromer one is definitely more useful, because when you are going for multiple inheritance, the only interface can do the job.
  • Question: Is there any method that simply have to be implemented by each and every task?
    Answer: Yes there is. All tasks must implement the run() method, doesn’t matter if we speak about subclass of Thread or implement the Runnable interface.

 

Some tricky java interview questions you can get

  • Question: To run Java programs, do I need to set on my machine any environment variables?
    Answer: Yes, you need to. PATH and also  CLASSPATH are the two variables you need to set on your machine to be able to run Java programs.
  • Question: Can you define Overriding?
    Answer: Overriding applies in a case when class defines a method using the same name, return type, and arguments as a method in its superclass. When this happens, the method in the class overrides the method in the superclass.
    Whenever the method is invoked for an object of the class, it will after be the new definition of the method that is called, and not the method definition from superclass. That is the basic description of overriding.
  • Question: Are objects in Java passed by the value or by the reference?
    Answer: Objects in Java are passed only by value, as Java does not support passing by reference. When we look at the object reference itself, it is so passed by value and both the original reference and parameter copy refer to the same object .
  • Question: Can you name the main difference between static and non-static variables in Java?
    Answer: The static variable is linked to the entire class rather than to specific instances of a particular class. Oppositely, non-static variable takes on unique value with every object instance.
  • Question: What will be the default value of local variables?
    Answer: In Java, local variables will not be initialized to any default value, neither primitives nor object references, that’s why you have to initialize every variable. In case try to use them without initializing them before, the java compiler will not compile the code at all.
  • Question: What is synchronization in Java and why it is essential?
    Answer: With respect to multithreading, synchronization is the ability to manage the accessibility of multiple threads to shared resources. Without having synchronization running, it will be possible for any thread to modify a shared object while some other thread is in the process of using or changing that exact object’s value. This will  lead to significant errors, that’s why the synchronozation is so important.

 

Java programmer is getting ready for java interview questionsA job of a java developer is becoming more and more popular, especially with the huge development of smart phone market. That’s why to succeed in the job interview, knowing the right answers to the java interview questions may not be sufficient. You should definitely have a look at some job interview tips and questions also. Well combined general and targeted preparation is the way towards success. Feel free to browse the site and prepare as good as possible for your interview.

Thank you for sharing...Share on Facebook7Share on Google+1Pin on Pinterest0Tweet about this on Twitter