can we declare local inner class as private?

No, local inner class cannot be declared as private or protected or public because local inner class is not associated with Object. Example of local inner class public class Main{ private String website="826.a00.myftpupload.com"; void show(){ class LocalInnerClass{ void display(){ System.out.println(website); } } LocalInnerClass localInnerClass = new LocalInnerClass(); localInnerClass.display(); } public static void main(String args[]){ Main … Read more

are true and false keywords in java?

No, true and false are not keywords in java. They are literals in java. As literals are reserved words in java so we cannot use them as identifiers in our program. Example public class Main { public static void main(String args[]){ int true = 10; String false = "jai"; } }public class Main { public … Read more

Abstraction vs Encapsulation in java

            Encapsulation                Abstraction 1. Encapsulation is a concept for wrapping of data and code into a single unit. 2. Encapsulation is a way of data hiding. 3. Encapsulation is achieved by access modifiers and classes. 4. Encapsulation solve the problem at implementation level. 1. Abstraction is a way to show only essential details to user. … Read more

Static vs dynamic binding in java

            Static binding              Dynamic binding Static binding in Java occurs during compile time. private, final and static methods and variables use static binding and are bonded by compiler Must not have any explicit return type. Static binding uses Type information  i.e. class in Java, for binding. Overloaded methods are bonded using static binding Dynamic binding occurs during runtime. virtual methods are bonded … Read more

can we declare constructor as final in java?

No, we cannot declare constructor as final in java. Java interview questions on final keyword what is final in java? What is final variable in java? What is final method in java? What is final class in java? What is blank final variable in java? What is static blank final variable in java? What is … Read more

Can we change the value of an interface field?

No, we can’t change the value of an interface field because interface fields are final and static by default. Example interface FinalTest{ String website = "w3schools.com"; } public class Main implements FinalTest{ void show(){ System.out.println(website); } public static void main(String args[]){ //creating object of Main Class Main obj = new Main(); obj.show(); } }interface FinalTest{ … Read more

what is the use of final class in java?

A final class is simply a class that can’t be extended. Main use of a final class is to prohibit inheritance in Java. This does not mean that all references to objects of the class would act as if they were declared as final. Java interview questions on final keyword what is final in java? … Read more

Abstract vs final method in java

An abstract method must be overridden in the sub class whereas final method cannot be overridden. Example: abstarct method overridden in subclass abstract class AbstractMethodTest{ abstract void show();   } public class Main extends AbstractMethodTest { void show() { System.out.println("Inside overridden show method"); } public static void main(String args[]){ //creating object of Main Class Main … Read more