|
| 1 | +//Exercise 15: Conclusion and Cleanup |
| 2 | +//15. Task: Go through all your code, ensure it compiles and runs correctly, |
| 3 | +// and print any final messages or observations you have made during the lab session. |
| 4 | + |
| 5 | +public class Main { |
| 6 | + public static void main(String[] args) { |
| 7 | + |
| 8 | + // Exercise 5: Working with Primitive Data Types |
| 9 | + byte byteContainer = 102; |
| 10 | + short shortContainer = 21; |
| 11 | + int intContainer = 1; |
| 12 | + long longContainer = 2423234293848223423L; |
| 13 | + float floatContainer = 21.2f; |
| 14 | + double doubleContainer = 2.232; |
| 15 | + char charContainer = 'f'; |
| 16 | + boolean booleanContainer = true; |
| 17 | + |
| 18 | + System.out.println("Byte value: " + byteContainer); |
| 19 | + System.out.println("Short value: " + shortContainer); |
| 20 | + System.out.println("Int value: " + intContainer); |
| 21 | + System.out.println("Long value: " + longContainer); |
| 22 | + System.out.println("Float value: " + floatContainer); |
| 23 | + System.out.println("Double value: " + doubleContainer); |
| 24 | + System.out.println("Char value: " + charContainer); |
| 25 | + System.out.println("Boolean value: " + booleanContainer); |
| 26 | + |
| 27 | + // Exercise 12: Basic Conditional Logic (if-else) |
| 28 | + int number = 5; |
| 29 | + if (number > 10) { |
| 30 | + System.out.println("Number is greater than 10"); |
| 31 | + } else { |
| 32 | + System.out.println("Number is less than or equal to 10."); |
| 33 | + } |
| 34 | + |
| 35 | + // Exercise 13: Using Ternary Operator |
| 36 | + boolean isAvailable = false; |
| 37 | + boolean available = isAvailable ? true : false; |
| 38 | + System.out.println("Availability: " + available); |
| 39 | + |
| 40 | + // Exercise 14: Exploring Strings |
| 41 | + String originalMessage = "Hello"; |
| 42 | + System.out.println("Initial String: " + originalMessage); |
| 43 | + String modifiedMessage = "World"; |
| 44 | + System.out.println("Modified String: " + modifiedMessage); |
| 45 | + |
| 46 | + // Conclusion and Final Observations |
| 47 | + System.out.println("--- Final Observations ---"); |
| 48 | + System.out.println("1. I have successfully demonstrated the use of different data types in Java."); |
| 49 | + System.out.println("2. The if-else statement works effectively for basic conditional logic."); |
| 50 | + System.out.println("3. The ternary operator provides a concise way to evaluate conditions."); |
| 51 | + System.out.println("4. I observed that strings in Java are immutable, as shown in the string exploration exercise."); |
| 52 | + System.out.println("5. Overall, the exercises reinforced my understanding of fundamental Java concepts."); |
| 53 | + } |
| 54 | +} |
0 commit comments