Can you have an inner class inside a method and what variables can you access?-

?– Yes, we can have an inner class inside a method and final variables can be accessed. Yes, in Java, you can have an inner class inside a method. This type of inner class is known as a local inner class. Local inner classes are defined within the body of a method, and they have … Read more

What is the difference between abstract class and interface

a) All the methods declared inside an interface are abstract whereas abstract class must have at least one abstract method and others may be concrete or abstract. b) In abstract class, key word abstract must be used for the methods whereas interface we need not use that keyword for the methods. c) Abstract class must … Read more

What is a cloneable interface and how many methods does it contain

?– It is not having any method because it is a TAGGED or MARKER interface. In Java, the Cloneable interface is a marker interface, which means it doesn’t contain any methods. Marker interfaces are used to indicate a special behavior or capability that a class should have. In the case of Cloneable, it indicates that … Read more

What is the difference between Integer and int?-

a) Integer is a class defined in the java. lang package, whereas int is a primitive data type defined in the Java language itself. Java does not automatically convert from one to the other. b) Integer can be used as an argument for a method that requires an object, whereas int can be used for … Read more

What is an abstract class?-

An abstract class is a class designed with implementation gaps for subclasses to fill in and is deliberately incomplete. An abstract class in Java is a class that cannot be instantiated (i.e., you cannot create an object of an abstract class directly). It is often used as a base class for other classes. Abstract classes … Read more