Recently asked Magna Infotech Technical Interview Questions with Answers

If my class is having 5 abstract methods then can I make it as an interface?

Can I display  logging messages on the console?

 Which cvs tool are you using? What are the methods that are there?


When I don’t want to commit the ResultSet obj content, what to do?


Difference between Checked & Unchecked Exception?
Checked Exceptions: Checked Exceptions deal compile time exception regarding the existence of  classes/interfaces But not syntax errors.
Ex:  ClassNotFoundException---when use a NULL referenced variable to call any  method/variable.
InterruptedException,---when two or more threads try to share same Resource(wait() and join())
NoSuchFieldException ---when we access the undeclared variable
NoSuchMethodException---when we invoke the undeclared method.
InstantiationException---when we try to create object for a abstract/interface
Unchecked Exceptions : deal runtime errors.
 Ex: ArithmeticException,

What is polymorphism? 
Poymorphism is the capability of an action/method to do different things based on an object that it is  acting upon.One form, many implementations.

keywords for Error handling ?
 (i) Catch - Declares the block of code used to handle an exception.
(ii) Finally - Block of code , usually following a typecatch statement, which is executed no matter what program flow occurs when dealing with an exception.
(iii) Throw - Used to pass an exception up to the method that calls this method.
(iv) Throws - Indicates the method will pass an exception to the method that called it.
(v) Try - Block of code that will be tried but which may cause an exception.
(vi) Assert - Evaluates a conditional _expression to verify the programmer's assumption. 

What is overloading and overriding?

Overloading is the process of re-defining a method for multiple times with different Signature.
Overriding is a process of re-defining a super class original version in its various derived classes through inheritance.

What is Encapsulation & abstraction?
Encapsulation is, a technique, used to encapsulate the properties &  behaviors of an object. It focuses on inside-view and solves problems at “implementation side”.
Abstraction refers to the act of representing essential features without including the background details

What is final ? 
class, method, variable.

How can you invoke a current class constructor from a method ?
Using “this”.

How can you invoke a super class constructor from derived class?
Using “super()”

What is “static”? 
method, variable, block, static nested class

What is “instanceOf”?

The operator that checks whether given instance is belongs to the given class or not.

Can I create an interface without methods, constants declarations? 

Can I place try & catch blocks in finally block? 


How can you make an ArrayList as Synchronized list?
List lobj=Collections.synchronizedArrayList(new ArrayLsit());
Map m=Collections.synchronizedMap(new HashMap());

What is Serialization?
Writing the state of an object in to Streams.

How can you made the fields of a class to not serialized?
Using the modifier called “transient”

What is the use with Generics?
It avoids explicit type casting.

What is “Reflection”?
It allows to do Mirror image operations on classes/interfaces to get the internal details.

How do you maintain versions in your project? 
Using SVN.

What is Junit?

A tool for unit testing.

What is session factory? How will you create a session factory? 
Ans: SessionFactory is Hibernate s concept of a single datastore and is threadsafe so that many threads can access it concurrently and request for sessions and immutable cache of compiled mappings for a single database. A SessionFactory is usually only built once at startup. SessionFactory should be wrapped in some kind of singleton so that it can be easily accessed in an application code.

SessionFactory sessionFactory = new Configuration().configure().buildSessionfactory();