The course is part of this learning path
In this course, we touch on key topics that should be known before learning the basics of Java.
Learning Objectives
- Java Output
- Java Input
- Java Comments
Intended Audience
- Anyone looking to get Oracle Java Certification
- Those who want to learn the Java Programming language from scratch
- Java developers who want to increase their knowledge
- Beginners with no previous coding experience in Java programming
- Those who want to learn tips and tricks in Oracle Certified Associate – Java SE 8 Programmer certification exams
Prerequisites
- No prior knowledge is required about the Java programming language.
- Basic computer knowledge
Hi there. Let's look at some questions about this section. As you can see a simple program is given and you're asked what the output of this program will be. You can pause the video here and try to solve it. I'll be giving the solution on the next slide. Yes, if you chose option C, you gave the correct answer. Let's examine the question now. If you notice, there are three print methods in the main method. Since the first is only the print method, the Hello statement is written to the console and the cursor stays on the same line.
Then the World statement in the println method is printed, just to the next of the Hello statement and the cursor moves to the next line because in the println method, the cursor continues from the next line after the expression is printed to the console. In the last print method, the Java expression is printed on the bottom line. Notice that there are two semicolons after the last line. But this does not prevent the program from running. You must put at least one semi colon at the end of a line. If you put more than one, it will not cause a compile error. Therefore the program will run and on the console screen Hello world will be printed on the first line and Java on the second line. So the answer is option C. Let's move on to the next question.
This question is about comment lines in Java. He asks which statement is correct. The first option has a /** and */ sign. This is the Java documentation comment sign. Option A is false. Option B has /* and */ which is the sign of a multiline comment. Option B is also wrong. The sign given an option C is not a comment line sign. Option C is also wrong. The // in option D is the single line comment sign and this option is correct. The answer is option D. Let's move on to the next question.
This question is about basic input in Java and it is asked which steps should be done to compile this code block. Here, stop the video and try to solve it yourself. I'll be giving the answer on the next slide. Yes, your answer is correct if you chose option A. If you remember, we had to import the scanner class in the java.util package in order to use the scanner class. Option B does not solve the error because args can be before or after square brackets. Option C also does not solve the error because having more than one semi colon will not cause an error. Option D is already wrong because the code will not work without importing the scanner class.
So the answer is option A. Let's move on to the next question. This question is about comment lines in Java. He asks which statement is not correct. The first option has a /** and */ sign. This is the Java documentation comment sign. Option A is true. Option B has /* and */, which is the sign of a multiline comment. Option B is also true. The // in option D is the single line comment sign, and this option is correct. The sign given in option C is not a comment line sign. Option C is also wrong, so the answer is option C. Let's take a short break here. I'll see you in the next video.
OAK Academy is made up of tech experts who have been in the sector for years and years and are deeply rooted in the tech world. They specialize in critical areas like cybersecurity, coding, IT, game development, app monetization, and mobile development.