It’s a great design question and asked a lot in java interviews. This post provides all the differences between abstract class and interface. When should we use interface over the abstract class and vice versa? The post also explains how to use abstract class and interface to create a flexi...
publicclassStringPrograms{publicstaticvoidmain(String[]args){Stringstr="123";System.out.println(reverse(str));}publicstaticStringreverse(Stringin){if(in==null)thrownewIllegalArgumentException("Null is not valid input");StringBuilderout=newStringBuilder();char[]chars=in.toCharArray();for(inti=chars....
An other approach to the same question You use an XOR swap. for example: int a = 5; int b = 10; a = a ^ b; b = a ^ b; a = a ^ b; What is data encapsulation? Encapsulation may be used by creating ‘get’ and ‘set’ methods in a class (JAVABEAN) which are used to ...
This is another common JUnit interview question asked atJava developer and tester interviews. Some core features of JUnit include: It allows developers and testers to perform regression testing It provides specific annotations for identifying various test methods It offers a platform that allows test ca...
Below are five examples of basic java problems. These questions are simple in nature, testing only one concept. They are meant to be solved in a collaborative integrated development environment (IDE). You can access the sample inputs, sample outputs, and base code for each question by ...
---these Java Interview Questions have been designed especially to get you acquainted with the nature of questions you may encounter during your interview for the subject of Java Programming Language. As per my experience. ---Good interviewers hardly planned to ask any particular question during yo...
This is a very common question if you are appearing for an interview for a junior-level programmer. Well, the most noticeable differences are as below: Variables declared in a Java interface is by defaultfinal. An abstract class may contain non-final variables. ...
Looking forward to appear in Java Interview, here are the key 100+ Java Interview Questions with Answers only for you including some of the tricky questions with answers. Table of Contents Sr.No.Question 1 What are new Java8 Features? 2 Difference between GET & POST METHODS? 3 Difference be...
This is acommonly asked Java algorithms interviewquestion. It tests your basic conceptual knowledge. Here’s how you can answer this:Quicksort, merge sort, heap sort, and insertion sort are some of the most used sorting algorithms. Q3. What are some examples of greedy algorithms?
6.2.1Interface can be used to implement the multiple inheritances while the abstract can not. Because the Java only provides the single inheritance. 6.2.2There is no implementation in the interfaces. But in abstract class, you can implement some common logic. ...