Loading...
Follow Us:

Corejava

Corejava

1. What is Java?

A high-level, object-oriented programming language designed to be platform-independent via the Java Virtual Machine (JVM).

2. What are the main features of Java?

Platform independence, object-oriented, security, automatic memory management (garbage collection), and multithreading.

3. What is the JVM?

The Java Virtual Machine, which executes Java bytecode and provides a runtime environment for Java applications.

4. What is the JDK?

Java Development Kit, a software development kit that includes tools for developing, compiling, and debugging Java applications.

5. What is the JRE?

Java Runtime Environment, which provides libraries and other components necessary to run Java applications.

6. What is a class?

A blueprint for creating objects that encapsulates data and methods.

7. What is an object?

An instance of a class containing both state and behavior.

8. What is inheritance?

A mechanism where a new class derives properties and behavior from an existing class.

9. What is polymorphism?

The ability of a single interface to represent different underlying forms (data types).

10. What is a wrapper class?

A class that encapsulates a primitive data type into an object.

11. What is the difference between == and .equals()?

== checks reference equality; .equals() checks value equality.

12. What is a constant in Java?

A variable declared with the final keyword, whose value cannot be changed.

13. What is the scope of a variable?

The visibility of a variable within different parts of the code (local, instance, static).

14. What are for, while, and do-while loops?

for loops iterate a fixed number of times; while loops execute as long as a condition is true; do-while guarantees at least one execution.

15. What is method overloading?

Defining multiple methods with the same name but different parameters.

16. What is method overriding?

Redefining a method in a subclass that already exists in the superclass.

17. What is the this keyword?

A reference to the current object instance.

18. What is the purpose of the static keyword?

To define class-level variables and methods that belong to the class rather than instances.

19. What is an exception?

An event that disrupts the normal flow of a program.

20. What is the purpose of try and catch?

To handle exceptions gracefully without crashing the program.

21. What is the finally block?

A block that executes after the try and catch, regardless of whether an exception occurred.

22. What is the difference between checked and unchecked exceptions?

Checked exceptions must be declared or handled; unchecked exceptions do not have to be explicitly handled.

23. What is the purpose of the throw keyword?

To explicitly throw an exception.

24. What is the Java Collections Framework?

A unified architecture for representing and manipulating collections of objects.

25. What is the difference between ArrayList and LinkedList?

ArrayList is backed by an array and provides fast random access; LinkedList is a doubly-linked list that provides fast insertions/deletions.

26. What is multithreading?

The ability to perform multiple tasks concurrently within a single program.

27. What is a thread?

A lightweight process that can run independently.

28. What is the Runnable interface?

A functional interface that represents a task that can be executed by a thread.

29. What is synchronization?

A mechanism to control access to shared resources by multiple threads.

30. What is the purpose of the volatile keyword?

To indicate that a variable's value may be changed by different threads.

31. What is serialization?

The process of converting an object into a byte stream for storage or transmission.

32. What is deserialization?

The process of converting a byte stream back into a copy of the original object.

33. What is an interface?

A reference type in Java that can contain only constants, method signatures, default methods, static methods, and nested types.

34. What is an abstract class?

A class that cannot be instantiated and may contain abstract methods (methods without a body).

35. What is dependency injection?

A design pattern that allows for the injection of dependencies into a class, promoting loose coupling.

36. What is a lambda expression?

A concise way to represent a function interface using an expression.

37. What is a design pattern?

A reusable solution to common software design problems.

38. What is the Singleton pattern?

A pattern that restricts the instantiation of a class to a single instance.

39. What is the Factory pattern?

A pattern that defines an interface for creating objects but allows subclasses to alter the type of objects that will be created.

40. What is the Observer pattern?

A pattern where an object (subject) maintains a list of dependents (observers) that are notified of state changes.

41. What is the Strategy pattern?

A pattern that defines a family of algorithms, encapsulates each one, and makes them interchangeable.

42. What is garbage collection?

The automatic process of reclaiming memory by removing objects that are no longer in use.

43. What is a memory leak?

A situation where memory that is no longer needed is not released, leading to increased memory usage.

44. What is the stack and heap memory?

Stack memory stores primitive types and references to objects; heap memory stores objects themselves.

45. What is a socket?

An endpoint for sending or receiving data across a network.

46. What is the difference between ServerSocket and Socket?

ServerSocket listens for incoming connections; Socket represents a connection to a client.

47. What is HTTP?

Hypertext Transfer Protocol, a protocol used for transferring data over the web.

48. What is REST?

Representational State Transfer, an architectural style for designing networked applications.

49. What is unit testing?

Testing individual components of a program for correctness.

50. What is JUnit?

A testing framework for Java used for unit testing.

51. What is exception handling?

A mechanism to handle runtime errors gracefully without crashing the program.

52. What are annotations?

Metadata that provides data about a program but is not part of the program itself.

53. What is reflection?

A feature that allows inspection of classes, methods, and fields at runtime.

54. What are Java's access modifiers?

public, private, protected, and package-private (default) which control visibility.

55. What is the synchronized keyword?

Used to ensure that a method or block of code is accessed by only one thread at a time.

56. What is Just-In-Time (JIT) compilation?

A process that improves performance by compiling bytecode into native machine code at runtime.

57. What is the purpose of the transient keyword?

To indicate that a field should not be serialized.

58. What is a memory model in Java?

A specification that describes how threads interact through memory and what behaviors are allowed.

59. What is the native keyword?

Indicates that a method is implemented in platform-specific code (usually C or C++).

60. What are default methods in interfaces?

Methods with an implementation that can be defined in interfaces.

61. What is the significance of public static void main(String[] args)?

It is the entry point for any Java application.

62. What is the difference between String, StringBuilder, and StringBuffer?

String is immutable; StringBuilder is mutable and not synchronized; StringBuffer is mutable and synchronized.

63. What is a package in Java?

A namespace that organizes a set of related classes and interfaces.


WhatsApp
Enquiry