0% found this document useful (0 votes)
2 views3 pages

Comprehensive Java Answers

The document provides a comprehensive overview of command prompt commands and basic Java programming concepts. It explains key terms such as directories, paths, and class structures, along with commands for file management and Java program execution. Additionally, it highlights the importance of the main method and differences in output methods in Java.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views3 pages

Comprehensive Java Answers

The document provides a comprehensive overview of command prompt commands and basic Java programming concepts. It explains key terms such as directories, paths, and class structures, along with commands for file management and Java program execution. Additionally, it highlights the importance of the main method and differences in output methods in Java.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Comprehensive Answers to Java Questions

COMMAND PROMPT

What is command Prompt?


A command-line interface used to execute commands for managing and troubleshooting
systems.

What is Directory?
A structure in a file system to organize files and other directories.

What is Working Directory?


The current directory in which the user is working and executing commands.

What is Root Directory?


The top-level directory in a file system that contains all other files and directories.

What is Absolute Path?


A complete path from the root directory to the target file or directory.

What is Relative Path?


A path relative to the working directory to reach a file or directory.

By using which command we can clear the screen?


The 'cls' command is used to clear the command prompt screen.

By using which command we can change the drive?


Typing the drive letter followed by a colon (e.g., D:) changes the drive.

By using which command we can create a folder?


The 'mkdir' or 'md' command is used to create a new folder.

By using which command we can rename the folder?


The 'ren' command is used to rename a folder.

By using which command we can remove the folder?


The 'rmdir' or 'rd' command is used to remove a folder.

By using which command we can list the folders?


The 'dir' command lists files and folders in a directory.

By using which command we can navigate the next single folder?


The 'cd <folder_name>' command navigates to a specified folder.
By using which command we can navigate the more than one next folder?
The 'cd <path>' command navigates through a hierarchy of folders.

By using which command we can navigate the previous folder?


The 'cd ..' command navigates to the parent directory.

By using which command we can navigate the more than one previous folder?
The 'cd ..\..' command navigates multiple levels up in the hierarchy.

By using which command we can exit the command Prompt?


The 'exit' command closes the command prompt.

BASIC STRUCTURE OF JAVA PROGRAM

Can we create a class without a main method?


Yes, but it will not execute independently. The main method is required for the program to
run.

Explain about Class Members?


Class members include fields (variables) and methods that define the properties and
behavior of a class.

What is Class block?


The class block is the body of the class enclosed within curly braces, where members are
defined.

What is the syntax to create a Class Block?


class ClassName { // class body }

What is Method Block?


A method block is a part of a class that contains a sequence of statements to perform a
specific task.

Why do we need the Main Method?


The main method serves as the entry point for program execution in Java.

List the statements used to print data in Java?


'System.out.println()', 'System.out.print()', and 'System.out.printf()'.

List the differences between System.out.println() and System.out.print()?


'println()' prints the data and moves to the next line, whereas 'print()' does not.

Can we write more than one semicolon at the end of printing statements?
Yes, but it is unnecessary and considered bad practice.

By using which command can we compile the Java source file?


'javac FileName.java' compiles the source file.
By using which command can we execute the Java .class file?
'java ClassName' runs the compiled .class file.

You might also like