Suppose you are using a Windows operating system and you wish to run an application. The application class is named App1 and is contained within the samples.java package. Choose the command that will run the application.

  1. java App1.samples.java

  2. java samples.java.App1

  3. javac samples.java.App1

  4. javac App1.samples.java


Correct Option: B
Explanation:

To run an application in Java, the user needs to know the correct command to execute. In this case, we are given the class name and package name of the application we wish to run.

Option A: java App1.samples.java - This option is incorrect because it uses an invalid syntax to run the application. The correct format is "java .".

Option B: java samples.java.App1 - This option is correct. By specifying the full package and class name, we can run the application using the Java Virtual Machine (JVM).

Option C: javac samples.java.App1 - This option is incorrect because the "javac" command is used to compile Java source code, not run an application.

Option D: javac App1.samples.java - This option is incorrect because it uses an invalid syntax to compile the application. The correct format is "javac /.java".

Therefore, the correct answer is:

The Answer is: B

Find more quizzes: