• +91 9723535972
  • info@interviewmaterial.com

Java Interview Questions and Answers

Java Interview Questions and Answers

Question - 81 : - What are the problems faced by Java programmers who don't use layout managers?

Answer - 81 : - Without layout managers, Java programmers are faced with determining how their GUI will be displayed across multiple windowing systems and finding a common sizing and positioning that will work within the constraints imposed by each windowing system.

Question - 82 : - What is the difference between static and non-static variables?

Answer - 82 : - A static variable is associated with the class as a whole rather than with specific instances of a class. Non-static variables take on unique values with each object instance.

Question - 83 : - What is the difference between the paint() and repaint() methods?

Answer - 83 : - The paint() method supports painting via a Graphics object. The repaint() method is used to cause paint() to be invoked by the AWT painting thread.

Question - 84 : - What is the purpose of the File class?

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

Question - 85 : - Why would you use a synchronized block vs. synchronized method?

Answer - 85 : - Synchronized blocks place locks for shorter periods than synchronized methods.

Question - 86 : - What restrictions are placed on method overriding?

Answer - 86 : - 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 - 87 : - What is casting?

Answer - 87 : - 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 - 88 : - Explain the usage of the keyword transient?

Answer - 88 : - 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).

Question - 89 : - What class allows you to read objects directly from a stream?

Answer - 89 : - The ObjectInputStream class supports the reading of objects from input streams.

Question - 90 : - How are this() and super() used with constructors?

Answer - 90 : - this() is used to invoke a constructor of the same class. super() is used to invoke a superclass constructor.


NCERT Solutions

 

Share your email for latest updates

Name:
Email:

Our partners