Lab Sheet: Unit 2 – Tokens, Expressions
and Control Structures
Course: Java Programming
Unit Duration: 5 Hours
Lab Questions:
1. Write a Java program to display all primitive data types with default values.
2. Accept a number and determine whether it is even or odd using if-else.
3. Write a Java program to swap two numbers using a temporary variable and also without
using a third variable.
4. Demonstrate use of pre-increment and post-increment operators with output.
5. Accept a character and check whether it is a vowel or consonant using switch-case.
6. Create a program to print multiplication table of a given number using a for loop.
7. Use a while loop to print Fibonacci series up to n terms entered by the user.
8. Demonstrate the use of break and continue within a loop with an example.
9. Use command-line arguments to accept a name and age and print a greeting.
10. Write a Java program to demonstrate type conversion between int, double, and float.