Advertisements
Advertisements
प्रश्न
Which of the following declarations are illegal and why?
- class abc(...)
- public class NumberOfDaysWorked(...)
- private int x;
- private class abc(...)
- default key getkey(...)
लघु उत्तर
उत्तर
- Illegal. The correct statement is class abc{.........}.
- Illegal. The accurate declaration is public class NumberOfDaysWorked{ ........... }.
- Legal.
- Illegal. The accurate expression is class abc{} as Java prohibits top-level classes from be designated as private. Inner or nested classes may be designated as private.
- Illegal. The correct statement is void getkey(.........).
Default access does not include a keyword. If there is no access specifier, it is regarded as default/friendly access.
shaalaa.com
या प्रश्नात किंवा उत्तरात काही त्रुटी आहे का?