This section contains carefully selected MCQs and Previous Year Questions with explanations to help students understand concepts and prepare effectively for examinations, interviews, and competitive tests.
Q: 1In the statement ‘System.out.println("Hello World!")’, the keyword 'out' stands for the following—
Option A
In Java, System.out.println("Hello World!") is used to print messages to the console.
| COMPONENT | TYPE | DESCRIPTION |
|---|---|---|
| System | System is a class, defined in java.lang package. | Provides access to standard input, output, and error streams; part of Java core library. |
| out | public static member of System class. | The out is an instance of the PrintStream class, which provides methods like println() to display output. |
| println() | Method of PrintStream class. | Prints the given message or value to the console and moves to the next line. |
Q: 2What is the right syntax to read an integer from the user in Java?
Option C
In Java, to read input from the user, we commonly use the Scanner class, which is part of the java.util package. First, a Scanner object is created using new Scanner(System.in), which connects the scanner to standard input like keyboard.
The Scanner class provides several methods to read different types of data. To read an integer, the correct method is nextInt().
You have reached the end of this topic. Continue learning with the next topic below.
Thank you so much for taking the time to read my Computer Science MCQs section carefully. Your support and interest mean a lot, and I truly appreciate you being part of this journey. Stay connected for more insights and updates! If you'd like to explore more tutorials and insights, check out my YouTube channel.
Don’t forget to subscribe and stay connected for future updates.