DEV Community

Alagupandi
Alagupandi

Posted on

Task-11

[Q.no.1]

Access modifiers are keywords that can be used to control the visibility of fields, methods, and constructors in a class. The four access modifiers in Java are public, protected, default, and private.

Significance:-
(i) Access specifiers define how the members (attributes and methods) of a class can be accessed. In the example above, the members are public - which means that they can be accessed and modified from outside the code.

(ii) Access Modifiers (Access Specifiers) are keywords that are used in OOP (object-oriented programming) in order to specify the accessibility of the methods, classes, constructors, and other members of the class.

[Q.no.2]

Difference between Exception and Error.

1)Exception:-

(i) Exceptions occur only at run time, just that checked exceptions can be detected at compile time.

(ii) Exceptions provide you the opportunity to make your program run in normal flow.

2)Error:-

(i) Errors occur at compile time and run time, which can terminate the compilation or execution.

(ii) Errors are also unchecked like Runtime Exceptions.

[Q.no.3]

Difference between checked exception and unchecked exception.

1)Checked Exception:-

(i) Checked exceptions happen at compile time when the source code is transformed into an executable code.

(ii) The checked exception is checked by the compiler.

(iii) Checked exceptions can be created manually.

2)Unchecked Exception:-

(i) Unchecked exceptions happen at runtime when the executable program starts running.

(ii) These types of exceptions are not checked by the compiler.

(iii) They can also be created manually.

OTHER QUESTIONS:-
https://github.com/alagu018/guvitask/tree/d15ac7d66c54746776f3a5d83a0ee1b1c89ea193/Task11

Top comments (0)