Computer Applications
Which of the following declarations are illegal and why?
(a) class abc{…}
(b) public class NumberOfDaysWorked{…}
(c) private int x;
(d) private class abc{…}
(e) default key getkey(…)
Answer
(a) class abc{…}
Legal
(b) public class NumberOfDaysWorked{…}
Legal
(c) private int x;
Legal
(d) private class abc{…}
Illegal — only 'public' or no access specifier are allowed for class declaration
(e) default key getkey(…)
Illegal — member method can't be explicitly marked 'default'