Exceptions

Introduction An exception represents an error condition that can occur during the normal course of program execution. When an exception occurs, it is said to be thrown. When it is thrown, the normal flow of the program terminates and the exception handling block will be executed. The execution handling block is the catch block. This …

Difference between Abstract vs. Interface

Abstract An abstract class can’t be instantiated, but it can be subclassed. An abstract class usually contains abstract and non-abstract methods that subclasses are forced to provide an implementation for. Abstract class doesn’t support multiple inheritance  Abstract class can have final, non-final, static and non-static variables  Abstract class can have static methods, main method and …

Java – While Statements

What is the difference between while and do while loop? Do while The do while loop will check the condition at the end of the loop. This way, the code inside the loop will be executed atleast once. Example Control-Flow While Loop The while loop checks a given condition. If the statement is true, the …

Java – Loop-and-a-half repetition control

Loop-and-a-half repetition control statements are used to control the flow of the loop. You wouldn’t want to run a loop forever. There will come a time when you need to stop a loop earlier and you can use the following statements to implement it: break; if statement while statement Example The break statement breaks out …

Java Interview Questions

1. What’s the difference between Abstract vs. Interface? ANSWER: An abstract class can’t be instantiated, but it can be subclassed. An abstract class usually contains abstract and non-abstract methods that subclasses are forced to provide an implementation for. An interface is a completely “abstract class” that is used to group related methods with empty bodies. …

Java: Access Modifiers

What is an Access modifier? Access modifiers are keywords used to specify the accessibility of a class (or type) and its members. These modifiers can be used from code inside or outside the current application.  Private Default Protected Public Private: Data members and methods that are declared private are used on within that specific class it …

Design a site like this with WordPress.com
Get started