Static, final, abstract and synchronized are considered as Non access modifiers in java.
static: It is used to represent the class members. It can be used with variable, method, initializer block and nested class.
final: It is used to restrict the further modification of instance variables, local variables , methods and classes.
abstract: abstract is used with class or method which must be enhanced or modified further.
synchronized: It is used to achieve thread safeness. It controls mutual exclusive problem in multithreading environment. Only one thread can access a resource at a particular instance of time. When a thread accesses a synchronized block or method, it acquires a lock on it and release the lock either after completion of method/block or any exception occur.
Java interview questions on access modifiers
- what are access modifiers in java?
- What are different types of access modifiers in java?
- What are non access modifiers in java?
- Can we use abstract and final both with a method?
- Can abstract class have final methods in java?
- Can we declare a class as private in java?
- Can we declare an abstract method as private?
- Can we declare a class as protected in java?