Java Assignment
Java Assignment
public Example() {
PI = 3.14;
}
2. Final Methods:
- When a method is declared as `final`, it cannot be overridden by subclasses.
- This is useful when you want to prevent subclasses from changing the behavior
of a particular method.
- Final methods are implicitly `final` in Java classes marked as `final`.
- Example:
public class Parent {
public final void display() {
System.out.println("This is a final method.");
}
}
3. What is a constructor? Does java provide default constructor? Does java provide a
default copy constructor? Explain with answer with suitable example.
4. Explain any 5 string class methods in detail.
5. What is private constructor?
6. Explain in detail the features of java.
7. Explain why the main function is declared as “public static void main(String args[])”?
8. Explain the concept of abstract classes in java.
9. What is the difference between Integer and int?
10. Explain jdk,jvm and jre .