In Java, what is the purpose of the 'public' keyword in a class declaration?
Question and options
In Java, what is the purpose of the 'public' keyword in a class declaration?
- It indicates that the class is publicly accessible from any package
- It specifies that the class is private and can only be accessed within its own package
- It declares a public method within the class
- It is not a valid keyword in class declarations
Answer and explanation
Correct answer: A - It indicates that the class is publicly accessible from any package
A public top-level class is accessible from classes in any package. Without public it is package-private.
Practice for these exams
-
CUSAT CAT M.Sc. Forensic Science
-
Uttarakhand Judicial Services
Subject revision
Related question papers
Related exam syllabi
More solved explanations in Computer fundamentals
- __________ refers to inability of the operating systems to allocate portions of unused memory.
- Which device is designed primarily to send typed input to a computer?
- In Computer and digital technology 1GB is
- Which programming language is widely used in Artificial Intelligence and Data Science?
- The output quality of a printer is measured by