Java Interview Questions & Answers

Showing 10 of 301 questions | Page 5

Technical interview questions and answers are essential for any Java Interview because Java is one of the most widely used programming languages in software development. Companies expect candidates to know OOP concepts, multithreading, exceptions, JDBC, collections, and real-time coding questions. Java interviews are commonly part of campus placements and software development roles in companies such as TCS, Infosys, Wipro, Cognizant, and Accenture. For freshers and job seekers, understanding Java concepts clearly makes it easier to clear technical rounds, online coding tests, and project discussions. This guide includes the most important and frequently asked Java interview questions with detailed explanations to help you prepare efficiently. These questions will help you gain confidence during software developer interviews and competitive placement tests.

Java professionals should deepen their expertise through J2EE development  concepts and data structures  fundamentals 

Showing 10 of 301 questions

41. Is String a primitive data type in Java?

No String is not a primitive data type in Java, even though it is one of the most extensively used object. Strings in Java are instances of String class defined in java.lang package.

42. Objects are passed by value or by reference?

Java only supports pass by value. With objects, the object reference itself is passed by value and so both the original reference and parameter copy both refer to the same object .

43. Primitive data types are passed by reference or pass by value?

Primitive data types are passed by value.

44. What are checked exceptions?

Checked exception are those which the Java compiler forces you to catch. e.g. IOException are checked Exceptions.

45. What are pass by reference and passby value?

Pass By Reference means the passing the address itself rather than passing the value. Passby Value means passing a copy of the value to be passed.

46. What are runtime exceptions?

Runtime exceptions are those exceptions that are thrown at runtime because of either wrong input data or because of wrong business logic etc. These are not checked by the compiler at compile time.

47. What are some alternatives to inheritance?

Delegation is an alternative to inheritance. Delegation means that you include an instance of another class as an instance variable, and forward messages to the instance. It is often safer than inheritance because it forces you to think about each message you forward, because the instance is of a known class, rather than a new class, and because it doesn't force you to accept all the methods of the super class: you can provide only the methods that really make sense. On the other hand, it makes you write more code, and it is harder to re-use (because it is not a subclass).

48. What are synchronized methods and synchronized statements?

Synchronized methods are methods that are used to control access to an object. A thread only executes a synchronized method after it has acquired the lock for the method's object or class. Synchronized statements are similar to synchronized methods. A synchronized statement can only be executed after a thread has acquired the lock for the object or class referenced in the synchronized statement.

49. What are synchronized methods and synchronized statements?

Synchronized methods are methods that are used to control access to an object. A thread only executes a synchronized method after it has acquired the lock for the method's object or class. Synchronized statements are similar to synchronized methods. A synchronized statement can only be executed after a thread has acquired the lock for the object or class referenced in the synchronized statement.

50. What are wrapper classes?

Java provides specialized classes corresponding to each of the primitive data types. These are called wrapper classes. They are e.g. Integer, Character, Double etc.
Questions and Answers for Competitive Exams Various Entrance Test