Lab 1 (Year 3 Sem 1)

Lab 1 is the second lab in semester 1 of year 3, and the second lab in the total of year 3. It is a lab for introducing students to Java, and is considered to be easy.

Description
Please complete the lab before start of school term.

Review Chapter 1 notes before attempting the questions.

Unlocked after completion

 * OCD (Score at least 60% for Lab 1: Introduction to Java)
 * Hello Java (Score at least 80% for Lab 1: Introduction to Java)

Files

 * [[Media:Chapter_1_-_Introduction_to_Java.pdf|Chapter 1 - Introduction to Java.pdf]]

Question
Java is the shortname for Javascript.

Options

 * True
 * False

Question
The creator of Java attempted to modify and extend the language from which language?

Options

 * Python
 * C++
 * C#
 * VB
 * Javascript

Question
Java originated from which company?

Options

 * Microsoft
 * Google
 * Sun Microsystems
 * Oracle
 * Amazon

Question
The name Java originated from

Options

 * a tree
 * a type of coffee
 * the name of the creator
 * the name of the company

Question
Java is a type of

Options

 * procedural language
 * object-oriented language

Question
What is the extension for Java source code files?

Options

 * .java
 * .class
 * .j
 * .js

Question
The .class file contains

Options

 * java source code
 * machine code
 * assembly code
 * bytecode

Question
What does JVM stands for?

Options

 * Java Vending Machine
 * Javascript Virtual Machine
 * Java Virtual Machine
 * Java Virtual Mechanism

Question
What should A, B and C be?



Options

 * A = JVM, B = IntelliJ, C = JDK
 * A = JDK, B = JVM, C = IntelliJ
 * A = IntelliJ, B = JDK, C = JVM
 * A = JDK, B = IntelliJ, C = JVM

Question
Which of the following can be used for writing comments in Java? (select all correct answers)

Options
◻ '‌'‌' comments '‌'‌'

◻ /* comments */

◻ # comments

◻ // comments

Question
Which of the following are features of Java? (Select all correct answer)

Options
◻ Java is portable.

◻ Java can be used for web applications and hand-held devices.

◻ Java supports garbage collection.

◻ Java compiler translates Java source code to machine code.

Question
Which of the following statement is FALSE?

Options

 * .class files contain abstract instructions for JVM
 * All programming languages have virtual machines
 * The same bytecode can be run on different JVM
 * The javac command is used to compile Java source code

Question
Which method is the starting point for all Java programs?

Options

 * main
 * class
 * static
 * void
 * public

Question
Which method prints text to the console in a Java program?

Options

 * System.printText
 * System.out.println
 * out.writeText
 * System.out

Question
Errors that are detected by the compiler are called

Options

 * syntax errors
 * runtime errors
 * logical errors
 * interpreted errors

Question
Division by zero is a common type of

Options

 * syntax error
 * runtime error
 * logical error
 * no error

Question
What is missing in the blank?



Options

 * java
 * class
 * public
 * static
 * void
 * main

Question
Consider the source code shown. What should the name of the java file be?



Options

 * Main.java
 * Hi.java
 * Hello.java
 * hello.java

Question
Open up IntelliJ and create a new Java Project.

Name it LAB1.

Take note of where the files are saved.

Create a new Java class and name it Welcome.

Copy and paste the code from PROGRAM1-1.

Compile and run the program.

Now, edit the code such that the following printout will be obtained:

+-+ | Welcome to CS3231. Yes it's a CS module! | +-+

Note that it needs to be formatted EXACTLY as shown to pass the autograder. There are 45 '-'s.

Copy and paste your code into the codebox below for autograding.

Solution
From the question itself, copy the printout. (DO NOT copy from the wiki as there might be formatting issues)

Replace the System.out.println in the template to print out the text.

Question
This Java program contains multiple errors and indentation problems.

Make relevant changes such that the program will compile correctly and output the following:

On a withered branch A crow has just alighted: Nightfall in autumn.

Also note that your source code must be properly indented.

Solution
Paste in the code from the last question, replacing the class name with  and also replace the println statements.

Question
What is the biggest difference between JDK 8 and JDK 9/10/11?

Options

 * JDK 8 is the only long term support version
 * JDK 9/10/11 uses the module system
 * JDK 8 has Javafx removed from the JDK
 * JDK 8 does not support lambda expressions

Question
Which version of JDK has Javafx removed from the JDK?

Options

 * JDK 8
 * JDK 9
 * JDK 10
 * JDK 11