JAVA INTERVIEW QUESTION
JAVA INTERVIEW QUESTION
Summary:
Shared by all threads: Method Area, Heap.
Thread-specific: Stack, Program Counter Register, Native Method Stack.
Q7. What If write static public void instead of Public static void ?
Ans. Both public static void and static public void will work the same way when declaring the main method in Java. The
program will run without issues.
2. Parameterized Constructor:
A constructor that takes parameters to initialize an object with specific values.
Useful when you want to provide initial values at the time of object creation.
Example:
3. Copy Constructor:
A copy constructor is a constructor used to create a new object by copying the values of an existing object of the same
class. It takes an object of the same class as a parameter.
Summary:
1. Default Constructor: No parameters, sets default values.
2. Parameterized Constructor: Takes parameters to initialize the object with specific values.
3. Copy Constructor: A constructor that creates a new object by copying the values from an existing object of the same
class.
Example of usage: