Set - 3

Question 21 :

Explain the usage of Java packages.

Answer :

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.


Question 22 :

Does the code in finally block get executed if there is an exception and a return statement in a catch block?

Answer :

If an exception occurs and there is a return statement in catch block, the finally block is still executed. The finally block will not be executed when the System.exit(1) statement is executed earlier or the system shut down earlier or the memory is used up earlier before the thread goes to finally block.


Question 23 :

Is Java a super set of JavaScript?

Answer :

No. They are completely different. Some syntax may be similar.


Question 24 :

What is a Container in a GUI?

Answer :

A Container contains and arranges other components (including other containers) through the use of layout managers, which use specific layout policies to determine where components should go as a function of the size of the container.


Question 25 :

How the object oriented approach helps us keep complexity of software development under control?

Answer :

We can discuss such issue from the following aspects:
Objects allow procedures to be encapsulated with their data to reduce potential interference.
Inheritance allows well-tested procedures to be reused and enables changes to make once and have effect in all relevant places.
The well-defined separations of interface and implementation allow constraints to be imposed on inheriting classes while still allowing the flexibility of overriding and overloading.