Set - 3

Question 1 :

What is the purpose of the File class?

Answer :

The File class is used to create objects that provide access to the files and directories of a local file system.

Question 2 :

Why would you use a synchronized block vs. synchronized method?

Answer :

Synchronized blocks place locks for shorter periods than synchronized methods.

Question 3 :

What restrictions are placed on method overriding?

Answer :

Overridden methods must have the same name, argument list, and return type. The overriding method may not limit the access of the method it overrides. The overriding method may not throw any exceptions that may not be thrown by the overridden method.

Question 4 :

What is casting?

Answer :

There are two types of casting, casting between primitive numeric types and casting between object references. Casting between numeric types is used to convert larger values, such as double values, to smaller values, such as byte values. Casting between object references is used to refer to an object by a compatible class, interface, or array type reference.

Question 5 :

Explain the usage of the keyword transient?

Answer :

This keyword indicates that the value of this member variable does not have to be serialized with the object. When the class will be de-serialized, this variable will be initialized with a default value of its data type (i.e. zero for integers).