Let's learn java programming language with easy steps. This Java tutorial provides you complete knowledge about java technology.

Thursday 31 August 2017

Interview Questions on Final Keyword in Java

Final Keyword Interview Questions in Java

Interview Questions on Final Keyword In Java

Here we are going to cover all the interview questions on final keyword in java. This is the most important article on final keyword which is mostly asked in any core java interviews.

In last post we have learned some interview questions on Exception Handling in java you can check this post.

There are many java keywords interview questions asked in core java interviews e.g static keyword in java interview questions, throw keyword interview questions, this keyword, etc. But here we will learn only java final keyword interview questions.


(1) What is final in Java?

Java final is a keyword or non-access modifier which is used to restrict the user.

(2) Where you can use final keyword in java?

There are many areas where we can use final keyword.
  • It can be used with the class.
  • It can be used with variables.
  • It can be used with methods.

(3) Can we inherit final class?

No, We cannot extend or inherit final class. If we will extend the final class, it will throw compile time error.


(4) Can we change the value of final variables?

No, After initializing final variable we cannot change the value of final variable because it becomes constant.

(5) Can we override final method?

No, We can't override final method in java programming language.

(6) Can we apply final keyword with main() method?

Yes, we can use final keyword with main() method in java.


(7) What is blank final variable?

A final variable which is not initialized at the time of declaration is known as blank final variable e.g...

final int a;//blank final variable

(8) What is static blank final variable?

A variable which is declared with static and final keyword without any initialization is called static blank final variable e.g...

static final int a;//static blank final variable

(9) How we can initialize blank final variables?

We can initialize blank final variables only in a constructor.

(10) How we can initialize static blank final variables?

We can initialize static blank final variable in static block only.


(11) Can we inherit final method in sub-class?

Yes, we can inherit final method in sub-class or child class.

(12) Can we declare java constructor as final?

No, we can't apply final keyword with the constructor.

(13) Can we create object for final class?

Yes, we can create object of final class but we cannot extend final class.

(14) Can we make interface as final?

No, we can't make interface as final because interface must be implemented in other classes.


(15) Difference between abstract method and final method in java?

Abstract method must be implemented or overridden in child class but we cannot override final method in child class or subclass.

(16) What is the difference between final, finally and finalize?

There are many differences between final, finally and finalize in java.

(17) What is the most common predefined final class object you used in a program?

Java String is a predefined final class object.

(18) Can we use non-final local variables inside a local inner class?

No, only final local variables can be used inside a local inner class.

Visit links:

Java Static Keyword Interview Questions.
Java Constructor Interview Questions.
Java Super Keyword Interview Questions.
Java Multithreading Interview Questions.
Java Interface Interview Questions.
Some Java Programs Using Final Keyword.

Here we discussed interview questions and answers on final keyword in java which will increase your concept skill for java questions on final keyword.

Share:

3 comments:

  1. nice java post on final keyword and I got full information from this.

    ReplyDelete
  2. Useful java post

    ReplyDelete

Facebook Page Likes

Follow javatutorial95 on twitter

Popular Posts

Translate