0% found this document useful (0 votes)
113 views8 pages

Lab 3 - Oop - Bitp 3113

BITP3113 OBJECT ORIENTED PROGRAMMING - LAB 3

Uploaded by

Razer69
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
113 views8 pages

Lab 3 - Oop - Bitp 3113

BITP3113 OBJECT ORIENTED PROGRAMMING - LAB 3

Uploaded by

Razer69
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

NAME: HARVINDHIRA A/L THRUGANAKUMAR

MATRIC ID: B032210433

BITP 3113 OBJECT ORIENTED PROGRAMMING


LAB 3

TASK 2

EXE 1

3. What is the content in Exe1? Write you answer below.

Greeting.java file

7. Please indicate the line number which the error has occurred. Line number: 11

8. Which of the following is the error message?

The class name is not the same as the Java file name.

9. How would you rectify this error?

Rename the class name as same as the java file name using Notepad++.

12. What kind of files produces upon successful compilation? Write your answer below.

Greetings.class file is produced.

13. Type java Greetings. Write the output displays on the console.

Welcome to Java
EXE 2

5. Write the Java command to compile the Java file in Exe2.


javac Greeting.java

7. Is there any error produce from your compilation? Tick where appropriate.
Yes

Specify the error using your own word. Specify the line number as well.

The error says there is a missing semicolon in line number 14.

10. Write file produces in directory Exe2 upon successful compilation.

Greeting.class file is produced.

14. Type java Message. Write the output displays on the console.

Java is Cool
Proceed with Other Exercises
Compile, debug and run all Java files in other directories. Record your error findings and output in the table below. Strike through the result where
appropriate.

Directory Filename Error Messages Remedy Expected Output Result


Exe3 Greeting.java Greeting.java:14: error: 1. Line 14 : change Static into The program displays "I PASS
<identifier> expected lower case (static) LOVE JAVA
public Static void PROGRAMMING!" on
Main(String[] args) { console.
^
Exe4 Greeting.java Error: public static void The program displays PASS
public static void main(String[] main(String[] args) { "Eat. Drink. Sleep. Dream.
args) .... JAVA" on console.
public class Greeting {
Error: Main method not found in
class Greeting
Exe5 Greeting.java :18: error: invalid method void main() { The program displays PASS
declaration; return type required "Java
main() { rules!!!" on console.
Exe6 MyClass.java 1. MyClass.java:16: error: ';' System.out.println("You The program displays PASS
expected made it!!!"); "Congratulation!!!" and
2. MyClass.java:17: error: Add semicolon at the end "You made it!!!" on
reached end of file while console
parsing
3. MyClass.java:11: error: class public class MyClas {
MyClas is public, should be into Class
declared in a file named
MyClas.java
public class MyClas {
Exe7 DemoClass.class Run this class Not applicable The program displays PASS
“Your
No error as the class is created so journey mastering Java
just run the class file begins now” on console.
Exe8 DemoClass.java 11: error: '{' expected public class Demo Class { The program displays “Its PASS
public class Demo Class { Demo Class Space a
^ rough ride ahead. Brace
DemoClass.java:14: error: invalid semicolon yourself!!!” on console.
method declaration; return type
required curly bracket
main(String[] args) {
^
DemoClass.java:16: error: ';'
expected
System.out.println("Its a
rough ride ahead. Brace
yourself!!!")

^
DemoClass.java:20: error: reached
end of file while parsing
}
^
4 errors
Exe9 DemoClass.java DemoClass.java:12: error: invalid void missing The program displays “I PASS
method declaration; return type come, I see, I conquer!”
required semicolon line 14 15 on
public static main(String[] console
args[]) { curly bracket line 18
^
DemoClass.java:14: error: ';' line 14 15 missing println
expected
System.out.print("I prob public static void
come, ") main(String[] args[]) {
^
DemoClass.java:15: error: ';'
expected
System.out.print("I see,
")
^
DemoClass.java:20: error: reached
end of file while parsing
}
^
4 errors
Exe10 DemoSpain.java DemoClass.java:11: error: class, erase 11 bracket The program will display PASS
interface, enum, or record expected +-------+
*/) line 13 add public | SPAIN |
^ +-------+
DemoClass.java:16: error: change int to void 16 on console.
unnamed classes are a preview
feature and are disabled by default. 18 20 semicolon missing
public static int main(String[]
args) {
^
(use --enable-preview to enable
unnamed classes)
DemoClass.java:18: error: ';'
expected
System.out.println("+----
---+")
^
DemoClass.java:20: error: ';'
expected
System.out.println("+----
---+")
^
DemoClass.java:23: error: class,
interface, enum, or record expected
}
^
5 errors
Exe11 WorldClass.java Error: Main method not found in line 12 add public The program will display PASS
class WorldClass, please define the "ITS A FLAT WORLD"
main method as: missing printline in few lines on
public static void main(String[] console.
args) incomplete String[] args
or a JavaFX application class must
extend
javafx.application.Application

C:\Users\student.MP1-
004\Documents\Lab1\Exe11>javac
WorldClass.java

C:\Users\student.MP1-
004\Documents\Lab1\Exe11>java
WorldClass
Error: Main method not found in
class WorldClass, please define the
main method as:
public static void main(String[]
args)
or a JavaFX application class must
extend
javafx.application.Application

C:\Users\student.MP1-
004\Documents\Lab1\Exe11>javac
WorldClass.java

C:\Users\student.MP1-
004\Documents\Lab1\Exe11>java
WorldClass
+-----------------------------
----------+
| |
| ITS A FLAT
WORLD |
| |
+-----------------------------
----------+

C:\Users\student.MP1-
004\Documents\Lab1\Exe11>^S

You might also like