The exception here is when a block that catches exceptions prompts the finally block to get executed. In other words, the finally block will be bypassed if there is no catch on the way to exit. The finally block will not execute and after System.exit () the program will be terminated. Will finally block execute if you put System.exit () in catch or try block? This can lead to compiler errors and since Java was designed to be simple, multiple inheritances are not supported. Here ambiguity arises when classes B and C inherit from class A and class D inherits from B and C. With multiple inheritances, one can run into the ‘diamond of death problem’. Why does Java not support multiple inheritances? Abstraction hides unwanted information whereas encapsulation hides the data into a single unit, protecting the information from outside influence. While abstraction focuses on an object’s behavior, encapsulation focuses on the implementation of an object’s behavior. In OOP, how does abstraction differ from encapsulation? It includes the JRE and tools like JavaDoc and Java Debugger. Conversely, the Java Development Kit (JDK) is a Software Development Kit, allowing one to develop, compile and execute applications and applets with Java. Java Runtime Environment (JRE) provides the requirements for Java programs to be executed and contains the JVM, Java class libraries and Java class loader. Practically, you can replace a class with its subclass and Java’s inheritance mechanism follows this principle. Liskov’s Substitution Principle prescribes that you can replace an object with an instance of its subtype without corrupting the program. Can you override a private method in Java? What’s the difference between CountDownLatch and CyclicBarrier? Why to use PreparedStatement over Statement? Distinguish between throw and throws in Java What do System.gc() and Runtime.gc() methods do? Can you store null keys/ values and duplicate keys/values in a Java HashMap? What’s the difference between fail-fast and fail-safe? Is Java pass-by-reference or pass-by-value? How can you ensure that N threads can access N resources without deadlock?
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |