Important Java Mcq 1

Which statement about a valid .java file is true?

a) It can only contain one class declaration.

b) It can contain one public class declaration and one public interface definition.

c) It must define at least one public class.

d) It may define at most one public class.

Answer

d) It may define at most one public class.

Explanation:

A valid .java file may define any number of classes or interfaces. However, It can only have at most one public class. Thus, Options A, B, and C are incorrect. Option D is the only correct answer.

Related MCQs

The main method header is written as?

a. public static void main(string[] args) b. public static void Main(string[] args) c. public static void main(Strings[] args) d. public static void main(String[] args) Answer:

A Java variable is the name of a

a. data value stored in memory that can change its value but cannot change its type during the program’s execution b. data type stored in

Aniket Malik

Aniket Malik

CERTIFIED TUTOR/TRAINER WITH 300+ REVIEWS

Facing difficulty with

this concept?