• +91 9723535972
  • info@interviewmaterial.com

Java Interview Questions and Answers

Java Interview Questions and Answers

Question - 101 : - How do you restrict a user to cut and paste from the html page?

Answer - 101 : - Using Servlet or client side scripts to lock keyboard keys. It is one of solutions.

Question - 102 : - What are the Object and Class classes used for?

Answer - 102 : - The Object class is the highest-level class in the Java class hierarchy. The Class class is used to represent the classes and interfaces that are loaded by a Java program.

Question - 103 : - What is Serialization and deserialization ?

Answer - 103 : - Serialization is the process of writing the state of an object to a byte stream. Deserialization is the process of restoring these objects.

Question - 104 : - Explain the usage of Java packages.

Answer - 104 : - This is a way to organize files when a project consists of multiple modules. It also helps resolve naming conflicts when different packages have classes with the same names. Packages access level also allows you to protect data from being used by the non-authorized classes.

Question - 105 : - Does the code in finally block get executed if there is an exception and a return statement in a catch block?

Answer - 105 : - If an exception occurs and there is a return statement in catch block, the finally block is still executed. The finally block will not be executed when the System.exit(1) statement is executed earlier or the system shut down earlier or the memory is used up earlier before the thread goes to finally block.

Question - 106 : - Is Java a super set of JavaScript?

Answer - 106 : - No. They are completely different. Some syntax may be similar.

Question - 107 : - What is a Container in a GUI?

Answer - 107 : - A Container contains and arranges other components (including other containers) through the use of layout managers, which use specific layout policies to determine where components should go as a function of the size of the container.

Question - 108 : - How the object oriented approach helps us keep complexity of software development under control?

Answer - 108 : - We can discuss such issue from the following aspects: Objects allow procedures to be encapsulated with their data to reduce potential interference. Inheritance allows well-tested procedures to be reused and enables changes to make once and have effect in all relevant places. The well-defined separations of interface and implementation allow constraints to be imposed on inheriting classes while still allowing the flexibility of overriding and overloading.

Question - 109 : - What is polymorphism?

Answer - 109 : - Polymorphism means "having many forms". It allows methods (may be variables) to be written that needn't be concerned about the specifics of the objects they will be applied to. That is, the method can be specified at a higher level of abstraction and can be counted on to work even on objects of un-conceived classes.

Question - 110 : - What is design by contract?

Answer - 110 : - The design by contract specifies the obligations of a method to any other methods that may use its services and also theirs to it. For example, the preconditions specify what the method required to be true when the method is called. Hence making sure that preconditions are. Similarly, postconditions specify what must be true when the method is finished, thus the called method has the responsibility of satisfying the post conditions. In Java, the exception handling facilities support the use of design by contract, especially in the case of checked exceptions. The assert keyword can be used to make such contracts.


NCERT Solutions

 

Share your email for latest updates

Name:
Email:

Our partners