SlideShare ist ein Scribd-Unternehmen logo
1 von 247
Downloaden Sie, um offline zu lesen
Java Lab
leonguyen.com
Outline
- Lab 01: An introduction to Java
- Lab 02: Java Language
- Lab 03: Class and Relationship
- Lab 04: Exception and debugging
- Lab 05: Thread
- Lab 06: Input/Output
- Lab 07: Generic programming and Collections
Github
https://github.com/leonguyen/JavaLab
Lab 01
An introduction to Java
Outline
- Download and install JDK
- Write a Helloworld program
- Install and use Eclipse to write a Java program
- Debugging Programs in Eclipse
Exercise 1
Download and install JDK
JDK & JRE
Task 1 - Download JDK
- Goto Java download site http://www.oracle.
com/technetwork/java/javase/downloads/index.html
Task 1 - Download JDK (cont)
- Select Java Platform (JDK), choose your operation platform (eg
Window X86) and download it
Task 2 - Install JDK
- Run the downloaded installer, which installs both the JDK (Java
Development Kit) and JRE (Java Runtime). By default the JDK and
JRE will be installed into directories C:Program FilesJava
Task 3 - Config PATH environment variables
- Windows Operating System searches the current directory and the
directories listed in the PATH environment variable for executable
programs invoked from the CMD shell. It helps programmer can
compile Java code in CMD shell.
- Click the "Start" button > "Control Panel" > "System" > (Vista/7 only)
"Advanced system settings"
Task 3 - Config PATH .. (cont)
Task 4 - Verify the JDK Installation
- Launch a CMD shell > type java –version to check that JDK is
properly installed and display its version, and javac to check Path work
properly too.
Exercise 2
Write a Helloworld program
Task 1 - Open your editor
- For example: Notepad++
Task 2 - Write your code
- Type this code bellow to editor window
Task 2 - Write your code (cont)
- Save the code in a file with the name Helloworld.java
- Note: File name must same as class name.
Task 3 - Compile and run on command-line
- Launch a CMD shell > type javac to compile the source code and
java to run the program using the JDK runtime
Exercise 3
Install and use Eclipse to write a
Java program
Task 1 - Download Eclipse
- Download Eclipse from http://www.eclipse.org/downloads. For
beginners, choose the minimal Eclipse IDE for Java Developers.
- Unzip the downloaded file into a directory of your choice.
Task 2 - Launch Eclipse
- Open eclipse.exe in the Eclipse installed directory
- Choose an appropriate directory for your workspace
Task 3 - Create a new Java Project
- Choose "File" menu > "New" > "Java project"
Task 4 - Write a Java program
- In the "Package Explorer" (left panel) > Right-click on "JavaLab" (or
use the "File" menu) > New > Class
Task 4 - Write a Java program (cont)
- Enter the following codes
Task 5 - Compile and Execute
- To run the program, right-click anywhere on the source file
"HelloWorld.java" (or from the "Run" menu) > Choose "Run As" > "Java
Application".
Exercise 4
Debugging Programs in Eclipse
Task 1 - Create project and write a simple
program
- Create a new class named Debug and enter the following code.
Task 2 - Set an Initial Breakpoint
- Set a breakpoint at main() method by double-clicking on the left-
margin of the line containing main().
Task 3 - Debug
- Right click anywhere on the source code (or from the "Run" menu) >
"Debug As" > "Java Application" > choose "Yes" to switch into "Debug"
perspective Step-Over and Watch the Variables and Outputs.
Lab 02
Java Language 01
Outline
- Relational & Logical Operators
- Types
- Scanner object
- If/else
- Switch case
- Command-Line Arguments
Outline (cont)
- OddEvenSum
- Compute PI
- Do While statement
- Array
- Loops and conditional statement
- Nested loop
- Break label
- Continue label
- Array Sort
- Reverse String
- Array of String
Exercise 1
Relational & Logical Operators
Task 1 - Create a RelationalLogicalOpTest
class
- Enter the following code.
Task 2 - Execute your program
- Choose "Run As" > "Java Application".
Exercise 2
Types
Task 1 - Create a TypesMinMax class
- Enter the following code.
Task 2 - Execute your program
- Choose "Run As" > "Java Application".
Exercise 3
Scanner object
Task 1 - Create a ScannerTest class
- Enter the following code.
Task 2 - Execute your program
- Choose "Run As" > "Java Application".
Exercise 4
If/else
Task 1 - Create a Mark class
- Enter the following code.
Task 2 - Execute your program
- Choose "Run As" > "Java Application".
Exercise 5
Switch case
Task 1 - Create a Month class
- Enter the following code.
Task 2 - Execute your program
- Choose "Run As" > "Java Application".
Exercise 6
Command-Line Arguments
Task 1 - Create a Arithemetic class
- Enter the following code.
Task 2 - Execute your program
- Choose "Run As" > "Java Application".
Lab 02 (cont)
Java Language 02
Exercise 1
OddEvenSum
Task 1 - Create a OddEvenSum class
- Enter the following code.
Task 2 - Execute your program
- Choose "Run As" > "Java Application".
Exercise 2
Compute PI
Task 1 - Create a ComputePI class
- Enter the following code.
Task 2 - Execute your program
- Choose "Run As" > "Java Application".
Exercise 3
Do While statement
Task 1 - Create a DoWhile class
- Enter the following code.
Task 2 - Execute your program
- Choose "Run As" > "Java Application".
Exercise 4
Array
Task 1 - Create a Arraytest class
- Enter the following code.
Task 2 - Execute your program
- Choose "Run As" > "Java Application".
Exercise 5
Loops and conditional statement
Task 1 - Create a PrimeList class
- Enter the following code.
Task 2 - Execute your program
- Choose "Run As" > "Java Application".
Exercise 6
Nested loop
Task 1 - Create a PrintPattern class
- Enter the following code.
Task 2 - Execute your program
- Choose "Run As" > "Java Application".
Exercise 7
Break label
Task 1 - Create a JavaGoto class
- Enter the following code.
Task 2 - Execute your program
- Choose "Run As" > "Java Application".
Exercise 8
Continue label
Task 1 - Create a ContinueLabel class
- Enter the following code.
Task 2 - Execute your program
- Choose "Run As" > "Java Application".
Exercise 9
Array Sort
Task 1 - Create a ArrayBubleSort class
- Enter the following code.
Task 2 - Execute your program
- Choose "Run As" > "Java Application".
Exercise 10
Reverse String
Task 1 - Create a ReverString class
- Enter the following code.
Task 2 - Execute your program
- Choose "Run As" > "Java Application".
Exercise 11
Array of String
Task 1 - Create a DayofWeek class
- Enter the following code.
Task 2 - Execute your program
- Choose "Run As" > "Java Application".
Lab 03
Class
Outline
- Booking Room
- Project assignment
What is OOP
Classes and Objects
Lab 03 (cont)
Class
Exercise 1
Booking Room
Class diagram
Task 1 - Create Date class
- Enter the following code.
Task 2 - Create Time class
- Enter the following code.
Task 3 - Create BookingRoomclass
- Enter the following code.
Task 3 - Create BookingRoomclass (cont)
- Enter the following code.
Task 3 - Create BookingRoomclass (cont)
- Enter the following code.
Task 3 - Create BookingRoomclass (cont)
- Enter the following code.
Task 4 - Write a Program class
- Enter the following code.
Task 5 - Execute your program
- Enter the following code.
Exercise 2
Project assignment
Class diagram
Task 1 - Create Teacher class
- Enter the following code.
Task 1 - Create Teacher class (cont)
- Enter the following code.
Task 2 - Create Student class
- Enter the following code.
Task 2 - Create Student class (cont)
- Enter the following code.
Task 3 - Write a Program class
- Enter the following code.
Task 4 - Execute your program
- Enter the following code.
Lab 04
Exception
Outline
- Exception
- Try-cath-finally
- Creating Your Own Exception Classes
- Assertion
Exercise 1
Exception
Diagram
- MobilePhone class to store mobile phone numbers and send a
messages to one of of numbers store in the array.
- PhoneTest class to demonstrate exception handling.
Task 1 - Create MobilePhone class
- Enter the following code.
Task 1 - Create MobilePhone class (cont)
- Enter the following code.
Task 2 - Create PhoneTest program
- Enter the following code.
Task 3 - Execute your program
- Enter the following code.
Exercise 2
Try-cath-finally
Task 1 - Create TryCatchFinally program
- Enter the following code.
Task 2 - Execute your program
- Choose "Run As" > "Java Application".
Exercise 3
Creating Your Own Exception
Classes
Task 1 - Create MyException class
- Enter the following code.
Task 2 - Create MyExceptionTest program
- Enter the following code.
Task 3 - Execute your program
- Choose "Run As" > "Java Application".
Exercise 4
Assertion
Task 1 - Create AssertionTest program
- Enter the following code.
Task 2 - Execute your program
- Choose "Run As" > "Java Application".
Exercise 5
Account in a Bank
Diagram
Diagram (cont)
The management of the A Bank is looking at automation as a means to
save time and effort required in their work. In order to achieve this, the
management has planned to computerize the following transactions:
• Creating a new account
• Withdrawing money from an account
• Depositing money in an account
The CEO of the company and a team of experts have chosen your
company to provide a solution for the same. Consider yourself to be a
part of the team that implements the solution for designing the
application.
Diagram (cont)
Create an application using exceptions and assertions to implement the
transactions. The application should consist of the following classes.
1. Account.java
2. Account Test.java
3. InsufficientFundException.java
4. NegativeAmountException.java
Each class has a specific purpose and functionality. The descriptions of
each class are as follows.
Task 1 - Create Account class
(The Account class represents an actual bank account. It stores the
following details of a bank account)
• customerName
• accountNumber
• accountbalance
• void displayAccountDetails() : This method displays the details of
the account
Task 1 - Create Account class (cont)
• void withdraw() : This method is used to withdraw money from an account.
This method accepts the account number and the amount to be withdrawn from
the account. The method then searches in the array of accounts for the account
number. Use assertions for checking whether the account number and the
amount to be withdrawn are positive. Also use an assertion to check if the array
of accounts contains a minimum of one account record. The method also
throws the user-defined exception InsufficientFund***ception in case the
amount to be withdrawn exceeds
• void deposit() :This method is used to deposit money in an account. The
account number and the amount to be deposited in the account is accepted
from the user. Use an assertion to check whether the account number is
positive. The method searches for the account number and deposits the
amount in the account if it exists. The displayAccountDetails() method is called
if the operation succeeds. Use appropriate try catch blocks to handle all the
possible exceptions that can be thrown due to the user inputs. A user-defined
exception is thrown if the account number does not exist.
Task 2 - Create AccountTest class
(The AccountTest class is a java main class used to test the Account
class. It creates an instance of the Account class and displays the
following menu of options to the user)
· Create a new account
· Withdraw Cash
· Deposit cash
· Exit
The user can select any of the options and a corresponding method is
invoked on the instance of the Bank class. Use an assertion to check
for the control-flow invariant in case the user types an invalid option.
The application exits when the Exit option is selected.
Task 3 - Create InsufficientFundException
class
- This is a user-defined exception class derived from the base class
Exception. This exception is thrown when the user tries to withdraw
more money than the current account balance.
Task 4 - Create NegativeAmountException
class
- This is a user-defined exception class derived from the base class
Exception. This exception is thrown when the user tries to withdraw or
deposit a negative amount.
Lab 05
Thread
Outline
- Use the Thread class
- Implement the Runable Interface
- Using join() to wait for threads to finish
- Thread priority
- Synchronization
- Dining Philosopher
Exercise 1
Use the Thread class
Task 1 - Create a RunThread class
- Enter the following code.
Task 2 - Main program
- Enter the following code.
Task 3 - Execute your program
- Choose "Run As" > "Java Application".
Exercise 2
Implement the Runable Interface
Task 1 - Create a RunThread1 class
- Enter the following code.
Task 2 - Main program
- Enter the following code.
Task 3 - Execute your program
- Choose "Run As" > "Java Application".
Exercise 3
Using join() to wait for threads to
finish
Task 1 - Create a MyThread class
- Enter the following code.
Task 2 - Main program
- Enter the following code.
Task 3 - Execute your program
- Choose "Run As" > "Java Application".
Exercise 4
Thread priority
Task 1 - Create Clicker class
- Enter the following code.
Task 2 - Main program
- Enter the following code.
Task 3 - Execute your program
- Choose "Run As" > "Java Application".
Exercise 5
Synchronization
Unsynchronized and synchronized
Task 1 - Create CountPrimesThread class
- Enter the following code.
Task 2 - Main program
- Enter the following code.
Task 2 - Main program (cont)
- Enter the following code.
Task 3 - Execute your program
- Choose "Run As" > "Java Application".
Exercise 6
Dining Philosopher
Concept
Task 1 - Create ChopStick class
- Enter the following code.
Task 2 - Create Philosopher class
- Enter the following code.
Task 2 - Create Philosopher class (cont)
- Enter the following code.
Task 2 - Main program
- Enter the following code.
Task 3 - Execute your program
- Choose "Run As" > "Java Application".
Lab 06
Input / Output
Stream
- Most fundamental I/O in Java is based on streams
- Reading information into a program
- Writing information from a program
java.io package
Outline
- Read a file - BufferedReader
- Write a file - BufferedWriter
- Write a file - FileOutputStream
- List the contents of a directory (Recursively)
- Copying a file without Buffering
- Copying a file with a Programmer-Managed Buffer
- Copying a file with Buffered Streams
- Best Copier
- InputStreamReader and OutputStreamWriter
- BufferedReader and BufferedWriter
- PipedReader and PipedWriter
- Serializable - ObjectOutputStream
Exercise 1
Read a file - BufferedReader
Task 1 - Create ReadFileBuffered program
- The simplest and most common-used method - BufferedReader.
Task 2 - Execute your program
- Choose "Run As" > "Java Application".
Exercise 2
Write a file - BufferedWriter
Task 1 - Create WriteFileBuffered program
- BufferedWriter is a character streams class to handle the character
data. Unlike bytes stream (convert data into bytes), you can just write
the strings, arrays or characters data directly to file.
Task 2 - Execute your program
- Choose "Run As" > "Java Application".
Exercise 3
Write a file - FileOutputStream
Task 1 - Create WriteFileStream program
- FileOutputStream is a bytes stream class that’s used to handle raw
binary data. To write the data to file, you have to convert the data into
bytes and save it to file.
Task 2 - Execute your program
- Choose "Run As" > "Java Application".
Exercise 4
List the contents of a directory
(Recursively)
Task 1 - Create ListDirectoryRecusive
program
- Enter the following code.
Task 2 - Execute your program
- Choose "Run As" > "Java Application".
Exercise 5
Copying a file without Buffering
Task 1 - Create FileCopyNoBuffer class
- Enter the following code.
Task 2 - Execute your program
- Choose "Run As" > "Java Application".
Exercise 6
Copying a file with a Programmer-Managed
Buffer
Task 1 - Create FileCopyUserBuffer class
- Enter the following code.
Task 2 - Execute your program
- Choose "Run As" > "Java Application".
Exercise 7
Copying a file with Buffered Streams
Task 1 - Create FileCopyBuffered class
- Enter the following code.
Task 2 - Execute your program
- Choose "Run As" > "Java Application".
Exercise 8
Best Copier
Task 1 - Create FileCopyUserBufferBest
class
- Enter the following code.
Task 2 - Execute your program
- Choose "Run As" > "Java Application".
Exercise 9
InputStreamReader and OutputStreamWriter
Task 1 - Create UnicodeFileIO program
- Enter the following code.
Task 2 - Execute your program
- Choose "Run As" > "Java Application".
Exercise 10
BufferedReader and BufferedWriter
Task 1 - Create UnicodeFileIOBuffered
program
- Enter the following code.
Task 2 - Execute your program
- Choose "Run As" > "Java Application".
Exercise 11
PipedReader and PipedWriter
Task 1 - Create pReader class
- Enter the following code.
Task 2 - Create pWriter class
- Enter the following code.
Task 3 - Main program
- Enter the following code.
Task 4 - Execute your program
- Choose "Run As" > "Java Application".
Exercise 12
Serializable - ObjectOutputStream
Task 1 - Create SerializedObject class
- Enter the following code.
Task 2 - Create SerializedObject class
- Enter the following code.
Task 3 - Execute your program
- Choose "Run As" > "Java Application".
Lab 07
Generic
Outline
- Generic class and Wildcard
- Student List
- ArrayList
- Employee Management
- LinkedList
- Set
- Map
Exercise 1
Generic class and Wildcard
Task 1 - Create Box class
- Enter the following code.
Task 2 - Create the program
- Enter the following code.
Task 3 - Execute your program
- Choose "Run As" > "Java Application".
Task 4 - Create A, B, C class
- Enter the following code.
Task 5 - Create BoxB, BoxC class
- Enter the following code.
Task 6 - Create Test BoxB, BoxC program
- Choose "Run As" > "Java Application".
Task 7 - Execute your program
- Choose "Run As" > "Java Application".
Exercise 2
Student List
Student List
Task 1 - Create Student class
- Enter the following code.
Task 2 - Create StudentList class
- Enter the following code.
Task 3 - Create the program
- Enter the following code.
Task 4 - Execute your program
- Choose "Run As" > "Java Application".
Exercise 3
ArrayList
Task 1 - Create ExArrayList program
- Enter the following code.
Task 2 - Execute your program
- Choose "Run As" > "Java Application".
Exercise 4
Employee Management
Task 1 - Create Employee class
- Enter the following code.
Task 2 - Create HREmpoyee class
- Enter the following code.
Task 3 - Create the program
- Enter the following code.
Task 4 - Execute your program
- Choose "Run As" > "Java Application".
Task 5 - Create EmpoyeeDetail class
- Enter the following code.
Task 6 - Edit the program
- Enter the following code.
Task 7 - Execute your program
- Choose "Run As" > "Java Application".
Exercise 5
LinkedList
Task 1 - Create ExLinkedList program
- Enter the following code.
Task 1 - Create ExLinkedList program (cont)
- Enter the following code.
Task 1 - Create ExLinkedList program (cont)
- Enter the following code.
Task 2 - Execute your program
- Enter the following code.
Exercise 6
Set
Task 1 - Create ListDirectoryRecusive class
- Enter the following code.
Task 2 - Execute your program
- Enter the following code.
Exercise 7
Map
Task 1 - Create ExMap program
- Enter the following code.
Task 1 - Create ExMap program (cont)
- Enter the following code.
Task 2 - Execute your program
- Enter the following code.

Weitere ähnliche Inhalte

Was ist angesagt?

Selenium web driver | java
Selenium web driver | javaSelenium web driver | java
Selenium web driver | javaRajesh Kumar
 
Test Case Creation in Katalon Studio
Test Case Creation in Katalon StudioTest Case Creation in Katalon Studio
Test Case Creation in Katalon StudioRapidValue
 
Selenium Automation Testing Interview Questions And Answers
Selenium Automation Testing Interview Questions And AnswersSelenium Automation Testing Interview Questions And Answers
Selenium Automation Testing Interview Questions And AnswersAjit Jadhav
 
Embrace Unit Testing
Embrace Unit TestingEmbrace Unit Testing
Embrace Unit Testingalessiopace
 
Testes? Mas isso não aumenta o tempo de projecto? Não quero...
Testes? Mas isso não aumenta o tempo de projecto? Não quero...Testes? Mas isso não aumenta o tempo de projecto? Não quero...
Testes? Mas isso não aumenta o tempo de projecto? Não quero...Comunidade NetPonto
 
Data driven testing
Data driven testingData driven testing
Data driven testingĐăng Minh
 
Qtp interview questions and answers
Qtp interview questions and answersQtp interview questions and answers
Qtp interview questions and answersITeLearn
 
TDD with Visual Studio 2010
TDD with Visual Studio 2010TDD with Visual Studio 2010
TDD with Visual Studio 2010Stefano Paluello
 
Testing Java applications with Maveryx
Testing Java applications with MaveryxTesting Java applications with Maveryx
Testing Java applications with MaveryxMaveryx
 
Mastering Mock Objects - Advanced Unit Testing for Java
Mastering Mock Objects - Advanced Unit Testing for JavaMastering Mock Objects - Advanced Unit Testing for Java
Mastering Mock Objects - Advanced Unit Testing for JavaDenilson Nastacio
 
Testing Options in Java
Testing Options in JavaTesting Options in Java
Testing Options in JavaMichael Fons
 
Selenium interview questions and answers
Selenium interview questions and answersSelenium interview questions and answers
Selenium interview questions and answerskavinilavuG
 
Joomla! Testing - J!DD Germany 2016
Joomla! Testing - J!DD Germany 2016Joomla! Testing - J!DD Germany 2016
Joomla! Testing - J!DD Germany 2016Yves Hoppe
 
Automation Testing with KATALON Cucumber BDD
Automation Testing with KATALON Cucumber BDDAutomation Testing with KATALON Cucumber BDD
Automation Testing with KATALON Cucumber BDDRapidValue
 
Creating testing tools to support development
Creating testing tools to support developmentCreating testing tools to support development
Creating testing tools to support developmentChema del Barco
 
Making Your Own Static Analyzer Using Freud DSL. Marat Vyshegorodtsev
 Making Your Own Static Analyzer Using Freud DSL. Marat Vyshegorodtsev Making Your Own Static Analyzer Using Freud DSL. Marat Vyshegorodtsev
Making Your Own Static Analyzer Using Freud DSL. Marat VyshegorodtsevYandex
 

Was ist angesagt? (20)

Selenium web driver | java
Selenium web driver | javaSelenium web driver | java
Selenium web driver | java
 
Test Case Creation in Katalon Studio
Test Case Creation in Katalon StudioTest Case Creation in Katalon Studio
Test Case Creation in Katalon Studio
 
Selenium Automation Testing Interview Questions And Answers
Selenium Automation Testing Interview Questions And AnswersSelenium Automation Testing Interview Questions And Answers
Selenium Automation Testing Interview Questions And Answers
 
Embrace Unit Testing
Embrace Unit TestingEmbrace Unit Testing
Embrace Unit Testing
 
Unit Testing 101
Unit Testing 101Unit Testing 101
Unit Testing 101
 
Testes? Mas isso não aumenta o tempo de projecto? Não quero...
Testes? Mas isso não aumenta o tempo de projecto? Não quero...Testes? Mas isso não aumenta o tempo de projecto? Não quero...
Testes? Mas isso não aumenta o tempo de projecto? Não quero...
 
Data driven testing
Data driven testingData driven testing
Data driven testing
 
Qtp interview questions and answers
Qtp interview questions and answersQtp interview questions and answers
Qtp interview questions and answers
 
The Seven Pillars Of Asp.Net
The Seven Pillars Of Asp.NetThe Seven Pillars Of Asp.Net
The Seven Pillars Of Asp.Net
 
TDD with Visual Studio 2010
TDD with Visual Studio 2010TDD with Visual Studio 2010
TDD with Visual Studio 2010
 
Testing Java applications with Maveryx
Testing Java applications with MaveryxTesting Java applications with Maveryx
Testing Java applications with Maveryx
 
Codeception
CodeceptionCodeception
Codeception
 
Mastering Mock Objects - Advanced Unit Testing for Java
Mastering Mock Objects - Advanced Unit Testing for JavaMastering Mock Objects - Advanced Unit Testing for Java
Mastering Mock Objects - Advanced Unit Testing for Java
 
Testing Options in Java
Testing Options in JavaTesting Options in Java
Testing Options in Java
 
Selenium interview questions and answers
Selenium interview questions and answersSelenium interview questions and answers
Selenium interview questions and answers
 
Joomla! Testing - J!DD Germany 2016
Joomla! Testing - J!DD Germany 2016Joomla! Testing - J!DD Germany 2016
Joomla! Testing - J!DD Germany 2016
 
Automation Testing with KATALON Cucumber BDD
Automation Testing with KATALON Cucumber BDDAutomation Testing with KATALON Cucumber BDD
Automation Testing with KATALON Cucumber BDD
 
Creating testing tools to support development
Creating testing tools to support developmentCreating testing tools to support development
Creating testing tools to support development
 
Why Unit Testingl
Why Unit TestinglWhy Unit Testingl
Why Unit Testingl
 
Making Your Own Static Analyzer Using Freud DSL. Marat Vyshegorodtsev
 Making Your Own Static Analyzer Using Freud DSL. Marat Vyshegorodtsev Making Your Own Static Analyzer Using Freud DSL. Marat Vyshegorodtsev
Making Your Own Static Analyzer Using Freud DSL. Marat Vyshegorodtsev
 

Andere mochten auch

Role of Expert System as a Knowledge Managment tool in water resource management
Role of Expert System as a Knowledge Managment tool in water resource managementRole of Expert System as a Knowledge Managment tool in water resource management
Role of Expert System as a Knowledge Managment tool in water resource managementIbrahim Ahmed
 
Matemática Básica
Matemática Básica Matemática Básica
Matemática Básica Alef Ribeiro
 
A importância da qualificação
A importância da qualificaçãoA importância da qualificação
A importância da qualificaçãoMárcio Melânia
 
Is Doing a Business Plan Worth the Time?
Is Doing a Business Plan Worth the Time?Is Doing a Business Plan Worth the Time?
Is Doing a Business Plan Worth the Time?ventureneer
 
A s lit and hist and riddle-1
A s lit and hist and riddle-1A s lit and hist and riddle-1
A s lit and hist and riddle-1stewby_123
 
Algebra Fx Kullanma Klavuzu 2
Algebra Fx Kullanma Klavuzu 2Algebra Fx Kullanma Klavuzu 2
Algebra Fx Kullanma Klavuzu 2BCanKARA
 
Why Curtis Funding?
Why Curtis Funding?  Why Curtis Funding?
Why Curtis Funding? Curt MacRae
 
Moodle como una herramienta de Enseñanza y Aprendizaje en la Educación Virtual
Moodle como una herramienta de Enseñanza y Aprendizaje en la Educación VirtualMoodle como una herramienta de Enseñanza y Aprendizaje en la Educación Virtual
Moodle como una herramienta de Enseñanza y Aprendizaje en la Educación VirtualDuglas Oswaldo Moreno Mendoza
 
Sleeping etiquette in Islam
Sleeping etiquette in Islam Sleeping etiquette in Islam
Sleeping etiquette in Islam Revert Islam
 
Taking care of your Website
Taking care of your WebsiteTaking care of your Website
Taking care of your WebsitePete S
 
ROOBUCK - "BUCKLITE"
ROOBUCK - "BUCKLITE"ROOBUCK - "BUCKLITE"
ROOBUCK - "BUCKLITE"Nishant Singh
 

Andere mochten auch (20)

Role of Expert System as a Knowledge Managment tool in water resource management
Role of Expert System as a Knowledge Managment tool in water resource managementRole of Expert System as a Knowledge Managment tool in water resource management
Role of Expert System as a Knowledge Managment tool in water resource management
 
Little child hairdress
Little child hairdressLittle child hairdress
Little child hairdress
 
Matemática Básica
Matemática Básica Matemática Básica
Matemática Básica
 
A importância da qualificação
A importância da qualificaçãoA importância da qualificação
A importância da qualificação
 
Is Doing a Business Plan Worth the Time?
Is Doing a Business Plan Worth the Time?Is Doing a Business Plan Worth the Time?
Is Doing a Business Plan Worth the Time?
 
Per op. in tha
Per op. in thaPer op. in tha
Per op. in tha
 
A s lit and hist and riddle-1
A s lit and hist and riddle-1A s lit and hist and riddle-1
A s lit and hist and riddle-1
 
Algebra Fx Kullanma Klavuzu 2
Algebra Fx Kullanma Klavuzu 2Algebra Fx Kullanma Klavuzu 2
Algebra Fx Kullanma Klavuzu 2
 
Spesifikasi window xp
Spesifikasi window xpSpesifikasi window xp
Spesifikasi window xp
 
Why Curtis Funding?
Why Curtis Funding?  Why Curtis Funding?
Why Curtis Funding?
 
Moodle como una herramienta de Enseñanza y Aprendizaje en la Educación Virtual
Moodle como una herramienta de Enseñanza y Aprendizaje en la Educación VirtualMoodle como una herramienta de Enseñanza y Aprendizaje en la Educación Virtual
Moodle como una herramienta de Enseñanza y Aprendizaje en la Educación Virtual
 
RELATÓRIO DE ESTAGIO
RELATÓRIO DE ESTAGIORELATÓRIO DE ESTAGIO
RELATÓRIO DE ESTAGIO
 
Sleeping etiquette in Islam
Sleeping etiquette in Islam Sleeping etiquette in Islam
Sleeping etiquette in Islam
 
Taking care of your Website
Taking care of your WebsiteTaking care of your Website
Taking care of your Website
 
Social media week 2011
Social media week 2011Social media week 2011
Social media week 2011
 
ROOBUCK - "BUCKLITE"
ROOBUCK - "BUCKLITE"ROOBUCK - "BUCKLITE"
ROOBUCK - "BUCKLITE"
 
Ansible
Ansible Ansible
Ansible
 
Roopmati pavilion
Roopmati pavilionRoopmati pavilion
Roopmati pavilion
 
Buku ajar nutrisi bedah
Buku ajar nutrisi bedahBuku ajar nutrisi bedah
Buku ajar nutrisi bedah
 
Lesson vi
Lesson viLesson vi
Lesson vi
 

Ähnlich wie Java Lab

Ähnlich wie Java Lab (20)

02 basic java programming and operators
02 basic java programming and operators02 basic java programming and operators
02 basic java programming and operators
 
Android Lab
Android LabAndroid Lab
Android Lab
 
Java part 1
Java part 1Java part 1
Java part 1
 
Java Intro: Unit1. Hello World
Java Intro: Unit1. Hello WorldJava Intro: Unit1. Hello World
Java Intro: Unit1. Hello World
 
Java lab1 manual
Java lab1 manualJava lab1 manual
Java lab1 manual
 
Unit of competency
Unit of competencyUnit of competency
Unit of competency
 
Cis 355 i lab 1 of 6
Cis 355 i lab 1 of 6Cis 355 i lab 1 of 6
Cis 355 i lab 1 of 6
 
Java For beginners and CSIT and IT students
Java  For beginners and CSIT and IT studentsJava  For beginners and CSIT and IT students
Java For beginners and CSIT and IT students
 
Java Programming
Java ProgrammingJava Programming
Java Programming
 
Lecture - 2 Environment setup & JDK, JRE, JVM
Lecture - 2 Environment setup & JDK, JRE, JVMLecture - 2 Environment setup & JDK, JRE, JVM
Lecture - 2 Environment setup & JDK, JRE, JVM
 
JAVA Program Examples
JAVA Program ExamplesJAVA Program Examples
JAVA Program Examples
 
Cis 355 ilab 1 of 6
Cis 355 ilab 1 of 6Cis 355 ilab 1 of 6
Cis 355 ilab 1 of 6
 
Cis 355 i lab 1 of 6
Cis 355 i lab 1 of 6Cis 355 i lab 1 of 6
Cis 355 i lab 1 of 6
 
How to write a simple java program in 10 steps
How to write a simple java program in 10 stepsHow to write a simple java program in 10 steps
How to write a simple java program in 10 steps
 
Java
JavaJava
Java
 
B.Sc. III(VI Sem) Advance Java Unit2: Appet
B.Sc. III(VI Sem) Advance Java Unit2: AppetB.Sc. III(VI Sem) Advance Java Unit2: Appet
B.Sc. III(VI Sem) Advance Java Unit2: Appet
 
How to run java program without IDE
How to run java program without IDEHow to run java program without IDE
How to run java program without IDE
 
Developing Java SWT Applications - A Starter
Developing Java SWT Applications - A StarterDeveloping Java SWT Applications - A Starter
Developing Java SWT Applications - A Starter
 
Java introduction
Java introductionJava introduction
Java introduction
 
Javalecture 1
Javalecture 1Javalecture 1
Javalecture 1
 

Kürzlich hochgeladen

UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPathCommunity
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsNathaniel Shimoni
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
Manual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditManual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditSkynet Technologies
 
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...panagenda
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...Wes McKinney
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Hiroshi SHIBATA
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesKari Kakkonen
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demoHarshalMandlekar2
 
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Scott Andery
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...AliaaTarek5
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfpanagenda
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesThousandEyes
 

Kürzlich hochgeladen (20)

UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to Hero
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directions
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
Manual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditManual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance Audit
 
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examples
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demo
 
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
 

Java Lab

  • 2. Outline - Lab 01: An introduction to Java - Lab 02: Java Language - Lab 03: Class and Relationship - Lab 04: Exception and debugging - Lab 05: Thread - Lab 06: Input/Output - Lab 07: Generic programming and Collections
  • 5. Outline - Download and install JDK - Write a Helloworld program - Install and use Eclipse to write a Java program - Debugging Programs in Eclipse
  • 8. Task 1 - Download JDK - Goto Java download site http://www.oracle. com/technetwork/java/javase/downloads/index.html
  • 9. Task 1 - Download JDK (cont) - Select Java Platform (JDK), choose your operation platform (eg Window X86) and download it
  • 10. Task 2 - Install JDK - Run the downloaded installer, which installs both the JDK (Java Development Kit) and JRE (Java Runtime). By default the JDK and JRE will be installed into directories C:Program FilesJava
  • 11. Task 3 - Config PATH environment variables - Windows Operating System searches the current directory and the directories listed in the PATH environment variable for executable programs invoked from the CMD shell. It helps programmer can compile Java code in CMD shell. - Click the "Start" button > "Control Panel" > "System" > (Vista/7 only) "Advanced system settings"
  • 12. Task 3 - Config PATH .. (cont)
  • 13. Task 4 - Verify the JDK Installation - Launch a CMD shell > type java –version to check that JDK is properly installed and display its version, and javac to check Path work properly too.
  • 14. Exercise 2 Write a Helloworld program
  • 15. Task 1 - Open your editor - For example: Notepad++
  • 16. Task 2 - Write your code - Type this code bellow to editor window
  • 17. Task 2 - Write your code (cont) - Save the code in a file with the name Helloworld.java - Note: File name must same as class name.
  • 18. Task 3 - Compile and run on command-line - Launch a CMD shell > type javac to compile the source code and java to run the program using the JDK runtime
  • 19. Exercise 3 Install and use Eclipse to write a Java program
  • 20. Task 1 - Download Eclipse - Download Eclipse from http://www.eclipse.org/downloads. For beginners, choose the minimal Eclipse IDE for Java Developers. - Unzip the downloaded file into a directory of your choice.
  • 21. Task 2 - Launch Eclipse - Open eclipse.exe in the Eclipse installed directory - Choose an appropriate directory for your workspace
  • 22. Task 3 - Create a new Java Project - Choose "File" menu > "New" > "Java project"
  • 23. Task 4 - Write a Java program - In the "Package Explorer" (left panel) > Right-click on "JavaLab" (or use the "File" menu) > New > Class
  • 24. Task 4 - Write a Java program (cont) - Enter the following codes
  • 25. Task 5 - Compile and Execute - To run the program, right-click anywhere on the source file "HelloWorld.java" (or from the "Run" menu) > Choose "Run As" > "Java Application".
  • 27. Task 1 - Create project and write a simple program - Create a new class named Debug and enter the following code.
  • 28. Task 2 - Set an Initial Breakpoint - Set a breakpoint at main() method by double-clicking on the left- margin of the line containing main().
  • 29. Task 3 - Debug - Right click anywhere on the source code (or from the "Run" menu) > "Debug As" > "Java Application" > choose "Yes" to switch into "Debug" perspective Step-Over and Watch the Variables and Outputs.
  • 31. Outline - Relational & Logical Operators - Types - Scanner object - If/else - Switch case - Command-Line Arguments
  • 32. Outline (cont) - OddEvenSum - Compute PI - Do While statement - Array - Loops and conditional statement - Nested loop - Break label - Continue label - Array Sort - Reverse String - Array of String
  • 33. Exercise 1 Relational & Logical Operators
  • 34. Task 1 - Create a RelationalLogicalOpTest class - Enter the following code.
  • 35. Task 2 - Execute your program - Choose "Run As" > "Java Application".
  • 37. Task 1 - Create a TypesMinMax class - Enter the following code.
  • 38. Task 2 - Execute your program - Choose "Run As" > "Java Application".
  • 40. Task 1 - Create a ScannerTest class - Enter the following code.
  • 41. Task 2 - Execute your program - Choose "Run As" > "Java Application".
  • 43. Task 1 - Create a Mark class - Enter the following code.
  • 44. Task 2 - Execute your program - Choose "Run As" > "Java Application".
  • 46. Task 1 - Create a Month class - Enter the following code.
  • 47. Task 2 - Execute your program - Choose "Run As" > "Java Application".
  • 49. Task 1 - Create a Arithemetic class - Enter the following code.
  • 50. Task 2 - Execute your program - Choose "Run As" > "Java Application".
  • 51. Lab 02 (cont) Java Language 02
  • 53. Task 1 - Create a OddEvenSum class - Enter the following code.
  • 54. Task 2 - Execute your program - Choose "Run As" > "Java Application".
  • 56. Task 1 - Create a ComputePI class - Enter the following code.
  • 57. Task 2 - Execute your program - Choose "Run As" > "Java Application".
  • 58. Exercise 3 Do While statement
  • 59. Task 1 - Create a DoWhile class - Enter the following code.
  • 60. Task 2 - Execute your program - Choose "Run As" > "Java Application".
  • 62. Task 1 - Create a Arraytest class - Enter the following code.
  • 63. Task 2 - Execute your program - Choose "Run As" > "Java Application".
  • 64. Exercise 5 Loops and conditional statement
  • 65. Task 1 - Create a PrimeList class - Enter the following code.
  • 66. Task 2 - Execute your program - Choose "Run As" > "Java Application".
  • 68. Task 1 - Create a PrintPattern class - Enter the following code.
  • 69. Task 2 - Execute your program - Choose "Run As" > "Java Application".
  • 71. Task 1 - Create a JavaGoto class - Enter the following code.
  • 72. Task 2 - Execute your program - Choose "Run As" > "Java Application".
  • 74. Task 1 - Create a ContinueLabel class - Enter the following code.
  • 75. Task 2 - Execute your program - Choose "Run As" > "Java Application".
  • 77. Task 1 - Create a ArrayBubleSort class - Enter the following code.
  • 78. Task 2 - Execute your program - Choose "Run As" > "Java Application".
  • 80. Task 1 - Create a ReverString class - Enter the following code.
  • 81. Task 2 - Execute your program - Choose "Run As" > "Java Application".
  • 83. Task 1 - Create a DayofWeek class - Enter the following code.
  • 84. Task 2 - Execute your program - Choose "Run As" > "Java Application".
  • 86. Outline - Booking Room - Project assignment
  • 92. Task 1 - Create Date class - Enter the following code.
  • 93. Task 2 - Create Time class - Enter the following code.
  • 94. Task 3 - Create BookingRoomclass - Enter the following code.
  • 95. Task 3 - Create BookingRoomclass (cont) - Enter the following code.
  • 96. Task 3 - Create BookingRoomclass (cont) - Enter the following code.
  • 97. Task 3 - Create BookingRoomclass (cont) - Enter the following code.
  • 98. Task 4 - Write a Program class - Enter the following code.
  • 99. Task 5 - Execute your program - Enter the following code.
  • 102. Task 1 - Create Teacher class - Enter the following code.
  • 103. Task 1 - Create Teacher class (cont) - Enter the following code.
  • 104. Task 2 - Create Student class - Enter the following code.
  • 105. Task 2 - Create Student class (cont) - Enter the following code.
  • 106. Task 3 - Write a Program class - Enter the following code.
  • 107. Task 4 - Execute your program - Enter the following code.
  • 109. Outline - Exception - Try-cath-finally - Creating Your Own Exception Classes - Assertion
  • 111. Diagram - MobilePhone class to store mobile phone numbers and send a messages to one of of numbers store in the array. - PhoneTest class to demonstrate exception handling.
  • 112. Task 1 - Create MobilePhone class - Enter the following code.
  • 113. Task 1 - Create MobilePhone class (cont) - Enter the following code.
  • 114. Task 2 - Create PhoneTest program - Enter the following code.
  • 115. Task 3 - Execute your program - Enter the following code.
  • 117. Task 1 - Create TryCatchFinally program - Enter the following code.
  • 118. Task 2 - Execute your program - Choose "Run As" > "Java Application".
  • 119. Exercise 3 Creating Your Own Exception Classes
  • 120. Task 1 - Create MyException class - Enter the following code.
  • 121. Task 2 - Create MyExceptionTest program - Enter the following code.
  • 122. Task 3 - Execute your program - Choose "Run As" > "Java Application".
  • 124. Task 1 - Create AssertionTest program - Enter the following code.
  • 125. Task 2 - Execute your program - Choose "Run As" > "Java Application".
  • 128. Diagram (cont) The management of the A Bank is looking at automation as a means to save time and effort required in their work. In order to achieve this, the management has planned to computerize the following transactions: • Creating a new account • Withdrawing money from an account • Depositing money in an account The CEO of the company and a team of experts have chosen your company to provide a solution for the same. Consider yourself to be a part of the team that implements the solution for designing the application.
  • 129. Diagram (cont) Create an application using exceptions and assertions to implement the transactions. The application should consist of the following classes. 1. Account.java 2. Account Test.java 3. InsufficientFundException.java 4. NegativeAmountException.java Each class has a specific purpose and functionality. The descriptions of each class are as follows.
  • 130. Task 1 - Create Account class (The Account class represents an actual bank account. It stores the following details of a bank account) • customerName • accountNumber • accountbalance • void displayAccountDetails() : This method displays the details of the account
  • 131. Task 1 - Create Account class (cont) • void withdraw() : This method is used to withdraw money from an account. This method accepts the account number and the amount to be withdrawn from the account. The method then searches in the array of accounts for the account number. Use assertions for checking whether the account number and the amount to be withdrawn are positive. Also use an assertion to check if the array of accounts contains a minimum of one account record. The method also throws the user-defined exception InsufficientFund***ception in case the amount to be withdrawn exceeds • void deposit() :This method is used to deposit money in an account. The account number and the amount to be deposited in the account is accepted from the user. Use an assertion to check whether the account number is positive. The method searches for the account number and deposits the amount in the account if it exists. The displayAccountDetails() method is called if the operation succeeds. Use appropriate try catch blocks to handle all the possible exceptions that can be thrown due to the user inputs. A user-defined exception is thrown if the account number does not exist.
  • 132. Task 2 - Create AccountTest class (The AccountTest class is a java main class used to test the Account class. It creates an instance of the Account class and displays the following menu of options to the user) · Create a new account · Withdraw Cash · Deposit cash · Exit The user can select any of the options and a corresponding method is invoked on the instance of the Bank class. Use an assertion to check for the control-flow invariant in case the user types an invalid option. The application exits when the Exit option is selected.
  • 133. Task 3 - Create InsufficientFundException class - This is a user-defined exception class derived from the base class Exception. This exception is thrown when the user tries to withdraw more money than the current account balance.
  • 134. Task 4 - Create NegativeAmountException class - This is a user-defined exception class derived from the base class Exception. This exception is thrown when the user tries to withdraw or deposit a negative amount.
  • 136. Outline - Use the Thread class - Implement the Runable Interface - Using join() to wait for threads to finish - Thread priority - Synchronization - Dining Philosopher
  • 137. Exercise 1 Use the Thread class
  • 138. Task 1 - Create a RunThread class - Enter the following code.
  • 139. Task 2 - Main program - Enter the following code.
  • 140. Task 3 - Execute your program - Choose "Run As" > "Java Application".
  • 141. Exercise 2 Implement the Runable Interface
  • 142. Task 1 - Create a RunThread1 class - Enter the following code.
  • 143. Task 2 - Main program - Enter the following code.
  • 144. Task 3 - Execute your program - Choose "Run As" > "Java Application".
  • 145. Exercise 3 Using join() to wait for threads to finish
  • 146. Task 1 - Create a MyThread class - Enter the following code.
  • 147. Task 2 - Main program - Enter the following code.
  • 148. Task 3 - Execute your program - Choose "Run As" > "Java Application".
  • 150. Task 1 - Create Clicker class - Enter the following code.
  • 151. Task 2 - Main program - Enter the following code.
  • 152. Task 3 - Execute your program - Choose "Run As" > "Java Application".
  • 155. Task 1 - Create CountPrimesThread class - Enter the following code.
  • 156. Task 2 - Main program - Enter the following code.
  • 157. Task 2 - Main program (cont) - Enter the following code.
  • 158. Task 3 - Execute your program - Choose "Run As" > "Java Application".
  • 161. Task 1 - Create ChopStick class - Enter the following code.
  • 162. Task 2 - Create Philosopher class - Enter the following code.
  • 163. Task 2 - Create Philosopher class (cont) - Enter the following code.
  • 164. Task 2 - Main program - Enter the following code.
  • 165. Task 3 - Execute your program - Choose "Run As" > "Java Application".
  • 166. Lab 06 Input / Output
  • 167. Stream - Most fundamental I/O in Java is based on streams - Reading information into a program - Writing information from a program
  • 169. Outline - Read a file - BufferedReader - Write a file - BufferedWriter - Write a file - FileOutputStream - List the contents of a directory (Recursively) - Copying a file without Buffering - Copying a file with a Programmer-Managed Buffer - Copying a file with Buffered Streams - Best Copier - InputStreamReader and OutputStreamWriter - BufferedReader and BufferedWriter - PipedReader and PipedWriter - Serializable - ObjectOutputStream
  • 170. Exercise 1 Read a file - BufferedReader
  • 171. Task 1 - Create ReadFileBuffered program - The simplest and most common-used method - BufferedReader.
  • 172. Task 2 - Execute your program - Choose "Run As" > "Java Application".
  • 173. Exercise 2 Write a file - BufferedWriter
  • 174. Task 1 - Create WriteFileBuffered program - BufferedWriter is a character streams class to handle the character data. Unlike bytes stream (convert data into bytes), you can just write the strings, arrays or characters data directly to file.
  • 175. Task 2 - Execute your program - Choose "Run As" > "Java Application".
  • 176. Exercise 3 Write a file - FileOutputStream
  • 177. Task 1 - Create WriteFileStream program - FileOutputStream is a bytes stream class that’s used to handle raw binary data. To write the data to file, you have to convert the data into bytes and save it to file.
  • 178. Task 2 - Execute your program - Choose "Run As" > "Java Application".
  • 179. Exercise 4 List the contents of a directory (Recursively)
  • 180. Task 1 - Create ListDirectoryRecusive program - Enter the following code.
  • 181. Task 2 - Execute your program - Choose "Run As" > "Java Application".
  • 182. Exercise 5 Copying a file without Buffering
  • 183. Task 1 - Create FileCopyNoBuffer class - Enter the following code.
  • 184. Task 2 - Execute your program - Choose "Run As" > "Java Application".
  • 185. Exercise 6 Copying a file with a Programmer-Managed Buffer
  • 186. Task 1 - Create FileCopyUserBuffer class - Enter the following code.
  • 187. Task 2 - Execute your program - Choose "Run As" > "Java Application".
  • 188. Exercise 7 Copying a file with Buffered Streams
  • 189. Task 1 - Create FileCopyBuffered class - Enter the following code.
  • 190. Task 2 - Execute your program - Choose "Run As" > "Java Application".
  • 192. Task 1 - Create FileCopyUserBufferBest class - Enter the following code.
  • 193. Task 2 - Execute your program - Choose "Run As" > "Java Application".
  • 194. Exercise 9 InputStreamReader and OutputStreamWriter
  • 195. Task 1 - Create UnicodeFileIO program - Enter the following code.
  • 196. Task 2 - Execute your program - Choose "Run As" > "Java Application".
  • 198. Task 1 - Create UnicodeFileIOBuffered program - Enter the following code.
  • 199. Task 2 - Execute your program - Choose "Run As" > "Java Application".
  • 201. Task 1 - Create pReader class - Enter the following code.
  • 202. Task 2 - Create pWriter class - Enter the following code.
  • 203. Task 3 - Main program - Enter the following code.
  • 204. Task 4 - Execute your program - Choose "Run As" > "Java Application".
  • 205. Exercise 12 Serializable - ObjectOutputStream
  • 206. Task 1 - Create SerializedObject class - Enter the following code.
  • 207. Task 2 - Create SerializedObject class - Enter the following code.
  • 208. Task 3 - Execute your program - Choose "Run As" > "Java Application".
  • 210. Outline - Generic class and Wildcard - Student List - ArrayList - Employee Management - LinkedList - Set - Map
  • 211. Exercise 1 Generic class and Wildcard
  • 212. Task 1 - Create Box class - Enter the following code.
  • 213. Task 2 - Create the program - Enter the following code.
  • 214. Task 3 - Execute your program - Choose "Run As" > "Java Application".
  • 215. Task 4 - Create A, B, C class - Enter the following code.
  • 216. Task 5 - Create BoxB, BoxC class - Enter the following code.
  • 217. Task 6 - Create Test BoxB, BoxC program - Choose "Run As" > "Java Application".
  • 218. Task 7 - Execute your program - Choose "Run As" > "Java Application".
  • 221. Task 1 - Create Student class - Enter the following code.
  • 222. Task 2 - Create StudentList class - Enter the following code.
  • 223. Task 3 - Create the program - Enter the following code.
  • 224. Task 4 - Execute your program - Choose "Run As" > "Java Application".
  • 226. Task 1 - Create ExArrayList program - Enter the following code.
  • 227. Task 2 - Execute your program - Choose "Run As" > "Java Application".
  • 229. Task 1 - Create Employee class - Enter the following code.
  • 230. Task 2 - Create HREmpoyee class - Enter the following code.
  • 231. Task 3 - Create the program - Enter the following code.
  • 232. Task 4 - Execute your program - Choose "Run As" > "Java Application".
  • 233. Task 5 - Create EmpoyeeDetail class - Enter the following code.
  • 234. Task 6 - Edit the program - Enter the following code.
  • 235. Task 7 - Execute your program - Choose "Run As" > "Java Application".
  • 237. Task 1 - Create ExLinkedList program - Enter the following code.
  • 238. Task 1 - Create ExLinkedList program (cont) - Enter the following code.
  • 239. Task 1 - Create ExLinkedList program (cont) - Enter the following code.
  • 240. Task 2 - Execute your program - Enter the following code.
  • 242. Task 1 - Create ListDirectoryRecusive class - Enter the following code.
  • 243. Task 2 - Execute your program - Enter the following code.
  • 245. Task 1 - Create ExMap program - Enter the following code.
  • 246. Task 1 - Create ExMap program (cont) - Enter the following code.
  • 247. Task 2 - Execute your program - Enter the following code.