Author: Editorial Team
-
Java – Try with Resources
1. Introduction ARM (Automatic Resource Management) using try-with-resources was added in Java 7. This is one of the small language changes added to JDK 7 as part of Project Coin. This feature makes it easier to work with external resources like files, printers, devices. A resource is an object that needs to be closed or…
-
Does an interface extends Object?
Consider the above code. We have defined an interface and have not provided any method in it. Since MyClass implements MyInterface, myInterface reference variable can be used to refer to a MyClass object. Thus, methods provided by interface can be invoked using variable myInterface. We can see from above code that interface has not defined any method, then the question comes to…
-
Why String is immutable in Java?
This is a design question. Following points can be given to support this: 1. Security – Consider a case when user is provided access to a particular path. But after getting access, user changes the path. This could be a serious security issue. String is the widely used type of parameter for many Java classes.…
