Professional Documents
Culture Documents
Let's Do Java: CS F213: Object Oriented Programming
Let's Do Java: CS F213: Object Oriented Programming
Dipanjan Chakraborty
Department of CS&IS
1/6
Program 1
●
Write a “Hello World” program in Java
●
Points to note:
– Java is whitespace agnostic meaning java doesnt care about indentation
2/6
Program 2
● Write a class NumberTester with one integer data
member number and a method testOddOrEven().
Using this test if different numbers are odd or even
from the main() method.
●
Points to note:
– How do the if and else constructs work in Java?
– What are valid identifiers in Java?
3/6
Program 3
●
Modify Program 2 to add a new method
isPrime() to the NumberTester class
●
Points to note:
– How does the for loop work in Java?
4/6
Program 4
●
Convert Program 3 to use:
– The while loop construct
– The do...while loop construct
●
What is the working difference between the
while and do...while loop?
5/6
Other constructs
●
In the lab you have also worked on / will work on:
– switch and case
– for-each
●
You have been introduced to arrays
●
These are similar to how they work on C, other than some
minor syntactical differences. We will get to them
eventually in the lectures
6/6