Tricky Java Interview Questions – Part 8
1. Tricky Java Interview Questions
Today, we are discussing the last part of our series tricky Java interview questions. These tricky Java interview questions will boost your knowledge and confidence to crack the Java interview in the first attempt. For more detailed knowledge, follow every link provided in tricky Java interview questions.
So, let’s start exploring tricky Java interview questions and answers.
2. Interview Questions for Java
Below, we are discussing some important tricky Java Interview Questions:
Q.1 Difference between a class and an object?
An object is an instance or living representation of the prototype whereas a class is a definition or prototype.
Q.2 What are the four cornerstones of OOP?
Polymorphism, Abstraction, Encapsulation, and Inheritance.
Q.3 Explain Java’s “write once and run anywhere” Nature?
Java compiles to a bytecode, the intermediate language between source code and machine code. This bytecode doesn’t platformed specific and hence often fed to any platform.
Q.4 How to restart a Dead Thread Be?
A dead thread can’t be restarted.
Q.5 What happens if an exception not caught?
It leads to the termination of the program within which through when an uncaught exception results in the uncaughtException() method of the thread’s ThreadGroup, it invokes.
Q.6 Describe a compilation unit?
A Java source code file.
Q.7 Explain a task’s priority and also tell how it is used in scheduling?
An integer value is the priority of a class that identifies the relative order in which it should be executed with respect to other tasks. The scheduler tries to schedule higher priority tasks before lower priority tasks.
Q.8 State the value which will Readline() return once it’s Reached the tip of a file?
Returns null once it reaches the end of a file.
Q.9 When will an object’s Finalize() method Invoke?
An object’s finalize() method can’t invoke by the garbage collector whereas the thing continues to be reachable. However, an object’s finalize() method could also invoke by different objects.
Tricky Java Interview Questions for freshers – Q. 1,2,3,4,6,8
Tricky Java Interview Questions for experienced – Q. 5,7,9
Q.10 Will garbage collection guarantee that a program won’t run out of memory?
Garbage collection doesn’t guarantee that a program won’t run out of memory. It’s possible for programs to use up memory resources quicker than they’re garbage collected. It’s also possible for programs to make objects that don’t subject to garbage pickup.
Q.11 Is Sizeof a keyword?
The sizeof operator isn’t a keyword.
Q.12 What state will a thread enter once it terminates its processing?
When a thread terminates its processing, it enters the dead state.
Q.13 Will a lock acquire on a class?
Yes, a lock often acquires on a class. This lock acquires on the class’s class object.
Q.14 How to use observer and Observable?
Objects that subclass the Observable class maintain a list of observers. An observable object once when update it invokes the update() method of every one of its observers to advise the observers that it’s changed state.
Q.15 What’s s transient variable?
A transient variable may a variable that will not serialize.
Q.16 What is the Output From System.out.println(“hello”+null);?
Q.17 What are E and Pi?
E is the base of the natural logarithm and PI is mathematical value pi.
Tricky Java Interview Questions for freshers – Q. 10,11,12,15,16,17
Tricky Java Interview Questions for experienced – Q. 13,14
Q.18 If an object is garbage collected, will it become reachable again?
Once associate degree object is garbage collected, it ceases to exist. It will not become reachable again.
Q.19 Will an exception is rethrown?
Yes, an exception often rethrown.
Q.20 What’s the purpose of the file class?
The File class use to make objects that give access to the files and directories of a local file system.
Q.21 Is a class subclass of itself?
No. a class isn’t a subclass of itself.
Q.22 What modifiers may use with an interface declaration?
An interface may declare as public or abstract.
Q.23 What classes of exceptions may catch by a catch clause?
A catch clause will catch any exception that will allot to the Throwable kind.
Q.24 Tell us the difference between the reader/writer class hierarchy and also the Inputstream/outputstream class Hierarchy?
The InputStream/OutputStream class hierarchy is byte-oriented and the reader/writer class hierarchy is character-oriented
Q.25 Will an Object Garbage Collected whereas it’s Still Reachable?
A reachable object can’t garbage collected. Solely unreachable objects may garbage collected.
Tricky Java Interview Questions for freshers – Q. 18,19,20,21,22,13
Tricky Java Interview Questions for experienced – Q. 24,25
Hence, you have completed the last part of our series tricky Java Interview Questions. Hope, these frequently asked tricky Java Interview Questions helped you to make your career brighter. Still, if any doubt regarding tricky Java Interview Questions, ask in the comment tab.