The document discusses coding a first Java program and running common errors that may occur. It provides 13 assignments where the reader is instructed to make errors in a sample Java program and observe the results. The goal is to learn about coding errors and how to address them.
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 ratings0% found this document useful (0 votes)
54 views
Object Oriented Programming With Java 2 - 1 PDF
The document discusses coding a first Java program and running common errors that may occur. It provides 13 assignments where the reader is instructed to make errors in a sample Java program and observe the results. The goal is to learn about coding errors and how to address them.
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/ 20
Programming with Java
Learning Java with Jagannath
Season 2 Episode 1 Session Objective • Using your android mobile for learning and running Java programs • Coding your first Java application and running it successfully • Learning about the various errors you may face while learning a Java program • Addressing various errors. Coding your first Java program • In Android Mobile – Using SoloLearn app or such similar app which has an IDE (integrated development environment) to type the Java program, compile and execute it • In Personal Computer /Laptop – Using Notepad to type the Java program and Command Prompt to compile and execute the program – Later on using BlueJ or Eclipse IDE Using SoloLearn or Similar Mobile App 1. Open Code Playground 2. Type your first Java program – class MyClass { public static void main(String [ ] args) { System.out.println(“Hello World”); } }
3. Save the program as MyClass.java
4. Press “RUN” to compile the code and execute it Using Notepad and Command Prompt 1. Open Notepad 2. Type your first Java program – class MyClass { public static void main(String [ ] args) { System.out.println(“Hello World”); } }
3. Save the program as MyClass.java
4. Open Command Prompt 5. Change over to the folder where you have saved the file 6. Type > javac MyClass.java 7. Type > java MyClass 8. You will get the output as shown beside (if you don’t have any error) Assignment 1 to be done in fair copy • Try out the following: – Type down the last program in MS Word, copy it and paste it in notepad and compile it. – What error do you get? Note it down – Why did we get that error? Write down the reason – Is there any typing error in your program? – Use the TYPE MyClass.java in command prompt to know the magic behind the error – Compare and note down the difference – Why did we get that error? Write down the reason Assignment 2 to be done in fair copy • Try out the following: – Type down the last program in notepad – Change the “class MyClass” to “Class MyClass” – Compile the program – What error do you get? Note it down – Change the “Class MyClass” back to “class MyClass” – Compile the program and run it – Why did we get that error? Write down the reason Assignment 3 to be done in fair copy • Try out the following: – Type down the last program in notepad – Save the file with filename as a different name such as My_Class etc. – Compile the program – Do you get any error? Note it down – Run the compiled program – What error do you get? Note it down – Why did we get that error? Write down the reason Assignment 4 to be done in fair copy • Try out the following: – Type down the last program in notepad without the opening curly brace – Save the file – Compile the program – What error do you get? Note it down – Why did we get that error? Write down the reason Assignment 5 to be done in fair copy • Try out the following: – Type down the last program in notepad – Change “public static void main(String [ ] args)” to “public static void main(int [ ] args)” – Save the file – Compile the program – Do you get any error? Note it down – Run the compiled program – What error do you get? Note it down – Why did we get that error? Write down the reason Assignment 6 to be done in fair copy • Try out the following: – Type down the last program in notepad – Change “public static void main(String [ ] args)” to “static void main(String [ ] args)” – Save the file – Compile the program – Do you get any error? Note it down – Run the compiled program – What error do you get? Note it down – Why did we get that error? Write down the reason Assignment 7 to be done in fair copy • Try out the following: – Type down the last program in notepad – Change “public static void main(String [ ] args)” to “ public void main(String [ ] args)” – Save the file – Compile the program – Do you get any error? Note it down – Run the compiled program – What error do you get? Note it down – Why did we get that error? Write down the reason Assignment 8 to be done in fair copy • Try out the following: – Type down the last program in notepad – Change “public static void main(String [ ] args)” to “ public static void main()” – Save the file – Compile the program – Do you get any error? Note it down – Run the compiled program – What error do you get? Note it down – Why did we get that error? Write down the reason Assignment 9 to be done in fair copy • Try out the following: – Type down the last program in notepad – Change “public static void main(String [ ] args)” to “ Public static void Main(String [ ] args)” – Save the file – Compile the program – Do you get any error? Note it down – Run the compiled program – What error do you get? Note it down – Why did we get that error? Write down the reason Assignment 10 to be done in fair copy • Try out the following: – Type down the last program in notepad – Remove the opening curly brace “{“ just after main – Save the file – Compile the program – Do you get any error? Note it down – Run the compiled program – What error do you get? Note it down – Why did we get that error? Write down the reason Assignment 11 to be done in fair copy • Try out the following: – Type down the last program in notepad – Change the System.out.println to system.out.println – Save the file – Compile the program – Do you get any error? Note it down – Run the compiled program – What error do you get? Note it down – Why did we get that error? Write down the reason Assignment 12 to be done in fair copy • Try out the following: – Type down the last program in notepad – Remove the opening quote or the closing quote before or after “HELLO WORLD” i.e. HELLO WORLD” or “HELLO WORLD – Save the file – Compile the program – Do you get any error? Note it down – Run the compiled program – What error do you get? Note it down – Why did we get that error? Write down the reason Assignment 13 to be done in fair copy • Try out the following: – Type down the last program in notepad – Remove the semi-colon (;) at the end of the line containing System.out.println() – Save the file – Compile the program – Do you get any error? Note it down – Run the compiled program – What error do you get? Note it down – Why did we get that error? Write down the reason Making the Error Table • Create the following table in your copy and note down the errors you faced in assignment 1 to 13 serially: Sl. No. The Error in the When occurred i.e. during Why did the error Program compiling or executing occurred? Submission • Submit the picture of the table in your assignment submission group latest by 13th May 2020, Wednesday, 4 pm