Home Java Technology Java Basics Java Questions - 4

Login Form




Java Questions - 4 Print E-mail

1. What are the advantages of OOPL?

Object oriented programming languages directly represent the real life objects. The features of OOPL as inhreitance, polymorphism, encapsulation makes it powerful.

 

2. What do you mean by multiple inheritance in C++ ?

Multiple inheritance is a feature in C++ by which one class can be of different types. Say class teachingAssistant is inherited from two classes say teacher and Student.

 

3. What are packages?

A package is a collection of related classes and interfaces providing access protection and namespace management.

 

4. What is the use of synchronizations?

Every object has a lock, when a synchronized keyword is used on a piece of code the, lock must be obtained by the thread first to execute that code, other threads will not be allowed to execute that piece of code till this lock is released.

 

5. In Java why we use exceptions?

Java uses exceptions as a way of signaling serious problems when you execute a program. One major benefit of having an error signaled by an exception is that it separates the code that deals with errors from the code that is executed when things are moving along smoothly. Another positive aspect of exceptions is that they provide a way of enforcing a response to particular errors.

 

6. How can we store the information returned from querying the database? and if it is too big, how does it affect the performance?

In Java the return information will be stored in the ResultSet object. Yes, if the ResultSet is getting big, it will slow down the process and the performance as well. We can prevent this situation by give the program a simple but specific query statement.

 

7. What is deadlock?

Deadlock is a situation when two threads are waiting on each other to release a resource. Each thread waiting for a resource which is held by the other waiting thread. In Java, this resource is usually the object lock obtained by the synchronized keyword.

 

8. What do you mean by static methods?

By using the static method there is no need creating an object of that class to use that method. We can directly call that method on that class. For example, say class A has static function f(), then we can call f() function as A.f(). There is no need of creating an object of class A.

 

9. What is a wrapper class?

They are classes that wrap a primitive data type so it can be used as a object

 

10. What is meant by final class, methods and variables?

This modifier can be applied to class method and variable. When declared as final class the class cannot be extended. When declared as final variable, its value cannot be changed if is primitive value, if it is a reference to the object it will always refer to the same object, internal attributes of the object can be changed.