Java Short Answer type Question
What's the difference between an interface and an abstract class?
An abstract class may contain code in method bodies, which is not allowed in an interface. With abstract classes, you have to inherit your class from it and Java does not allow multiple inheritances. On the other hand, you can implement multiple interfaces in your class.
How can you force garbage collection?
We can't force Garbage Collection but could request it by calling System.gc(). JVM does not guarantee that Garbage Collection will be started immediately.
Explain the usage of Java packages.
This is a way to organize files when a project consists of multiple modules. It also helps resolve naming conflicts when different packages have classes with the same names. Packages access level also allows you to protect data from being used by the non-authorized classes.
Post A Comment:
0 comments: