480 Core Java Interview Questions (Part 5)

This guide having 480 Core Java interview questions will help you in revising most asked core java interview questions for both junior and senior developers.

80 Core Java Interview Questions (Part 5)

401.What is Optional in Java 8?
402.What are the uses of Optional?
403.Which method in Optional provides the fallback mechanism in case of
null value?
404.How can we get current time by using Date/Time API of Java 8?
405.Is it possible to define a static method in an Interface?
406.How can we analyze the dependencies in Java classes and packages?
407.What are the new JVM arguments introduced by Java 8?
408.What are the popular annotations introduced in Java 8?
409.What is a StringJoiner in Java 8?
410.What is the type of a Lambda expression in Java 8?
411. What is the target type of a lambda expression ?
412.What are the main differences between an interface with default
method and an abstract class in Java 8?
Java Tricky Questions
413.Is there any difference between a = a + b and a += b expressions?
414.What does the expression 1.0 / 0.0 return? Will there be any
compilation error?
415.Can we use multiple main methods in multiple classes?
416.Does Java allow you to override a private or static method?
417.What happens when you put a key object in a HashMap that is
already present?418.How can you make sure that N threads can access N resources
without deadlock?
419.How can you determine if JVM is 32-bit or 64-bit from Java
Program?
420.What is the right data type to represent Money (like Dollar/Pound) in
Java?
421.How can you do multiple inheritances in Java?
422.Is ++ operation thread-safe in Java?
423.How can you access a non-static variable from the static context?
424.Let say there is a method that throws NullPointerException in the
superclass. Can we override it with a method that throws
RuntimeException?
425.How can you mark an array volatile in Java?
426.What is a thread local variable in Java?
427.What is the difference between sleep() and wait() methods in Java?
428.Can you create an Immutable object that contains a mutable object?
429.How can you convert an Array of bytes to String?
430.What is difference between CyclicBarrier and CountDownLatch
class?
431.What is the difference between StringBuffer and StringBuilder?
432.Which class contains clone method? Cloneable or Object class?
433.How will you take thread dump in Java?
434.Can you cast an int variable into a byte variable? What happens if the
value of int is larger than byte?
435.In Java, can we store a double value in a long variable without explicitcasting?
436.What will this return 5*0.1 == 0.5? true or false?
437.Out of an int and Integer, which one takes more memory?
438.Can we use String in the switch case statement in Java?
439.Can we use multiple main methods in same class?
440.When creating an abstract class, is it a good idea to call abstract
methods inside its constructor?
441.How can you do constructor chaining in Java?
442.How can we find the memory usage of JVM from Java code?
443.What is the difference between x == y and x.equals(y) expressions in
Java?
444. How can you guarantee that the garbage collection takes place?
445.What is the relation between x.hashCode() method and x.equals(y)
method of Object class?
446.What is a compile time constant in Java?
447.Explain the difference between fail-fast and fail-safe iterators?
448. You have a character array and a String. Which one is more secure
to store sensitive data (like password, date of birth, etc.)?
449.Why do you use volatile keyword in Java?
450.What is the difference between poll() and remove() methods of Queue
in Java?
451.Can you catch an exception thrown by another thread in Java?
452.How do you decide which type of Inner Class – Static or Non-Static to
use in Java?
453.What are the different types of Classloaders in Java?454.What are the situations in which you choose HashSet or TreeSet?
455.What is the use of method references in Java?
456.Do you think Java Enums are more powerful than integer constants?
457.Why do we use static initializers in Java?
458.Your client is complaining that your code is throwing
NoClassDefFoundError or NoSuchMethodError, even though you are able
to compile your code without error and method exists in your code. What
could be the reason behind this?
459.How can you check if a String is a number by using regular
expression?
460.What is the difference between the expressions String s =
“Temporary” and String s = new String(“Temporary “)? Which one is
better and more efficient?
461.In Java, can two equal objects have the different hash code?
462.How can we print an Array in Java?
463.Is it ok to use random numbers in the implementation of hashcode()
method in Java?
464.Between two types of dependency injections, constructor injection
and setter dependency injection, which one is better?
465.What is the difference between DOM and SAX parser in Java?
466.Between Enumeration and Iterator, which one has better performance
in Java?
467.What is the difference between pass by reference and pass by value?
468.What are the different ways to sort a collection in Java?
469.Why Collection interface doesn’t extend Cloneable and Serializable
interfaces?470.What is the difference between a process and a thread in Java?
471.What are the benefits of using an unordered array over an ordered
array?
472.Between HashSet and TreeSet collections in Java, which one is
better?
473.When does JVM call the finalize() method?
474.When would you use Serial Garabage collector or Throughput
Garbage collector in Java?
475.In Java, if you set an object reference to null, will the Garbage
Collector immediately free the memory held by that object?
476.How can you make an Object eligible for Garbage collection in Java?
477.When do you use Exception or Error in Java? What is the difference
between these two?
478.What is the advantage of PreparedStatement over Statement class in
Java?
479.In Java, what is the difference between throw and throws keywords?
480.What happens to the Exception object after the exception handling is
done?

That’s all about 480 Core Java Interview Questions.

Leave a Comment

*

Please share it if you found this useful
Hide Buttons