SQL Command: Statement

In order fo your JDBC to use sql queries, your program must understand it is a SQL command and not just random gibberish you are typing. How would you use a statement command? Statement statementName = connection.createstatement();Statement is the interface;statementName is the name of the statement you are creating;connection.createstatement () – connection is the object …

Javadoc – Documentation made easy

Java standardized the documentation process so everyone follows the same convention when documenting their code. You can easily read the required documentation instead of scratching your head on other people’s documentation. Javadoc is created using a JDK javadoc tool. The tool converts the documentation to fresh, standard and easy HTML page.No hassle! Example Order of …

Multiple Default Methods in Inheritence

Back in the day, it was hard to add functionalities to inheritance without breaking the whole program., But now you can! How? You have to use default methods. Whenever there is a need for a new method in inheritance, it can be done without implementing the method in every single class implementing the interface. What …

Can a Semaphore act as a Mutex?

ANSWER: Let’s define both these terms. Semaphore: A semaphore control access to a shared resource using a counter. The counter measures the number of permits that are allowed. If a counter is zero, then access to the resource is denied. If it is greater than zero, then access to the resource allowed. Every time a …

What’s the difference between a class method and an instance method?

ANSWER: Class methods are declared as static hence they can be called without creating an instance of a class. Class methods can only operate on class members and not on instance variables since they are unaware of the instance members. In order to use an instance method, you must create a instance of a class …

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. …

Design a site like this with WordPress.com
Get started