Home Interview Questions and AnswersPlacement Papers with AnswersHeadstrong HeadStrong Java Placement Paper For Freshers Part-3

head strong21. What is the difference between an array and a vector?

Number of elements in an array are fixed at the construction time, whereas the number of elements in vector can grow dynamically.
22. What is a constructor?

In Java, the class designer can guarantee initialization of every object by providing a special method called a constructor. If a class has a constructor, Java automatically calls that constructor when an object is created, before users can even get their hands on it. So initialization is guaranteed.

23. What is casting?

Conversion of one type of data to another when appropriate. Casting makes explicitly converting of data.

24. What is the difference between final, finally and finalize?

The modifier final is used on class variable and methods to specify certain behaviour explained above. And finally is used as one of the loop in the try catch blocks, It is used to hold code that needs to be executed whether or not the exception occurs in the try catch block. Java provides a method called finalize( ) that can be defined in the class. When the garbage collector is ready to release the storage ed for your object, it will first call finalize( ), and only on the next garbage-collection pass will it reclaim the objects memory. So finalize( ), gives you the ability to perform some important cleanup at the time of garbage collection.

25. What is are packages?

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

26. What is a super class and how can you call a super class?

When a class is extended that is derived from another class there is a relationship is created, the parent class is referred to as the super class by the derived class that is the child. The derived class can make a call to the super class using the keyword super. If used in the constructor of the derived class it has to be the first statement.

27. What is meant by a Thread?

Thread is defined as an instantiated parallel process of a given program.

28.  What is multi-threading?

Multi-threading as the name suggest is the scenario where more than one threads are running.

29. What are two ways of creating a thread? Which is the best way and why?

Two ways of creating threads are, one can extend from the Java.lang.Thread and can implement the rum method or the run method of a different class can be called which implements the interface Runnable, and the then implement the run() method. The latter one is mostly used as first due to Java rule of only one class inheritance, with implementing the Runnable interface that problem is sorted out.

30.  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.

You may also like

Leave a Comment