Midterms

Midterm Quizzes

These are the quizzes taken during the midterm period.

Quiz # 1

Score: 27/30
â–¼
💡 Quiz Summary

The quiz covers the important concepts in Java, starting from its history and introduction to how a Java program is structured. It helps reinforce understanding of variables, methods, and how different parts of a program work together. It also reviews operators, which are used for calculations and decision-making in code, and control structures that manage the flow of a program through conditions and loops. It connects these topics in a way that helps deepen understanding of how Java is actually used in programming.

Midterm Seatworks

These are the seatworks completed during the midterm period.

Seatwork # 1

Score: 30/30
â–¼
💡 Seatwork Summary

This seatwork focused on unary operators in Java and how they affect the value of variables in a program. The task was to analyze a program step by step and determining the correct output for each line. This helped in understanding how increment and decrement operators work, especially when they are used in different forms like pre-increment and post-increment. This improved the ability of logically tracing and carefully following how values change throughout program execution.

Seatwork # 2 - Tuition Fee Payment

Score: 30/30
â–¼
💡 Seatwork Summary

The hands-on paper seatwork focused on analyzing a tuition fee payment problem using a switch statement. It required carefully understanding the given scenario and determining how different cases should be handled in the program.

Midterm Assignments

These are the assignments completed during the midterm period.

Assignment # 1 - About Me

Download PDF
Grade: 30/30
â–¼
About Me Assignment
💡 Assignment Summary

This assignment serves as a creative introduction, showcasing personal background, aspirations, and the journey toward learning Java programming.

Assignment # 2 - Introduction to Java

Download PDF
Grade: 30/30
â–¼
Q1. What is the Java Programming Language? Discuss its key features and advantages.

Java is a high-level, general purpose, memory-safe, object-oriented programming language. It allows developers to write code that can run on any device with a JVM, which makes it highly portable. It is widely used for building applications, such as mobile apps, web applications, and software applications.

Q2. Explain the concept of platform independence in Java. How does Java achieve platform independence?

The concept of "Write Once, Run Anywhere" (WORA), which is made possible by the JVM that interprets compiled code (bytecode) into machine-specific instructions, regardless of the computer's operating system and hardware.

Q3. Discuss the main components of a Java program and their roles.
  • Package - group of classes and interfaces that organizes the code
  • Class - defines variables and methods
  • Method - a block of code that performs a specific task
  • Variable - a name memory location used to store and manipulate data
  • Statement - an instruction that performs an action
Q4. What are the differences between JDK, JRE, and JVM in Java?
  • Java Development Kit (JDK) - it contains all the tools that are required to compile, debug, and run a program, using the Java platform. It is the foundational component that enables Java application and Java applet development.
  • Java Runtime Environment (JRE) - a set of software tools responsible for execution of the Java program or application
  • Java Virtual Machine (JVM) - it loads, verifies, and runs Java bytecode and is necessary in both JDK and JRE. It can also run programs that are written in other programming languages that have been converted to Java bytecode.
Q5. Explain the difference between interpreted and compiled languages. Is Java an interpreted or compiled language?

Interpreted languages execute code first without compiling while compiled languages require the code to be translated into machine code before executing. Java is considered a hybrid language because it is both compiled and interpreted. The source code is compiled into bytecode and then interpreted by the JVM.

References
  • Wikipedia
  • Geeks for Geeks
  • IBM

Midterm Activities

These are the activities created and completed during the midterm period.

Midterm Activity #1 - Variables

Download PDF
Grade: 27/30
â–¼
Instructions:
  • Carefully analyze the given Java program.
  • Trace the references and memory changes step-by-step.
  • Complete all required tables and questions.
  • Show your logical reasoning where necessary.

class Student {
      String name;
      int grade;
       
      Student(String n, int g) {
            name = n;
            grade = g;
       }
}

public class TestStudent {
       public static void main (String[] args) {
                Student s1 = new Student ("John", 85);
                Student s2 = new Student ("Maria", 90);
                Student s3 = s2;

                s1.grade = 95;
                s3.name = "Ana";
 
                System.out.println(s1.name + " " + s1.grade);
                System.out.println(s2.name + " " + s2.grade);
                System.out.println(s3.name + " " + s3.grade);
        }
}
Part A - Variable Identification Table
Variable Name Data Type Variable Type Stored In
name String Instance Heap
grade int Instance Heap
s1 Student Local Stack
s2 Student Local Stack
s3 Student Local Stack
n String Local Stack
g int Local Stack
Part B - Explanation
Statement What Happens? Memory Impact
Student s1 = new Student("John", 85); Creates a new student and stores it at s1, "John" 85 Created in Heap -> s1 Stack
Student s2 = new Student("Maria", 90); Creates a new student and stores it at s2, "Maria" 90 Created in Heap -> s2 Stack
Student s3 = s2; s3 is assigned the same as s2, Maria 90 -> s3 s2 & s3 -> same in Heap
s1.grade = 95; Updates the grade of s1, John 95 s1 grade becomes 95
s3.name = "Ana"; Updates the name of s3, Ana 90 s2 name becomes "Ana" which also becomes s3
Part C - Output

It will print:


John 95
Ana 90
Ana 90
💡 Key Explanation

This shows how Java stores objects in memory using the stack and heap. Variables s1, s2, and s3 are stored in the stack and hold references to objects in the heap. When s3 = s2, both point to the same object, changing one also changes the other. Unlike s1 which is separate, so its changes does not affect the others.

Midterm Activity #2 - Operators

Download PDF
Grade: 30/30
â–¼
Instructions:
  • Create a Java program based on the questions.
  • Follow the exact required output shown in the question.
  • You must use the specific operator required in each number.
  • Show proper use of variables and correct operator usage.
  • Follow proper Java syntax, indentation, and naming conventions.
Part I
1. Create a Java program using bitwise operators that will produce the output: true, 10, false, 15.
Part I - 1 Java Code
2. Create a Java program using the ternary operator that will produce the output: true, false, 25, 30.
Part I - 2 Java Code
3. Create a Java program using assignment operators that will produce the output: Addition: 120, Subtraction: 70, Multiplication: 144, Division: 16.
Part I - 3 Java Code
Part II
Program Requirements:
  • Use at least five (5) different operators from the following categories:
    • Arithmetic operators (+, -, *, /, %)
    • Relational operators (>, <, >=, <=, ==, !=)
    • Logical operators (&&, ||, !)
    • Unary operators (++, --)
    • Assignment operators (+=, -=, *=, /=)
    • Bitwise operators (&, |, ^, <<, >>)
  • The program must produce exactly six (6) outputs only.
  • At least one output must include a tricky increment or decrement case, such as:
    • a++ + ++a
    • --b + b++
    • or any similar expression that modifies the variable within the same statement.
  • Do NOT reuse:
    • Any variable values
    • Any variable names
    • Any logic patterns from Part I.
  • The output must contain:
    • At least two (2) boolean results
    • At least four (4) numeric results
Part II Java Code
💡 Key Explanation

The activity helps understand how different Java operators work and how they affect variables and program output. This strengthens the ability to trace expressions, predict outputs, and correctly apply operators in Java programs.

Midterm Activity #3 - ATM with Transfer Feature

Download PDF
Grade: 30/30
â–¼
Program Requirements:
  1. Create a Java program named ATMWithdrawalLimit.
  2. Assume the initial balance is 9,000 pesos.
===== ATM MENU =====
  • 1. Check Balance
  • 2. Deposit
  • 3. Withdraw
  • 4. Exit
Withdrawal Rules:
  • Maximum withdrawal per transaction: 3,000 pesos
  • If exceeded, display: Withdrawal Limit Exceeded
Use:
  • if-else statements
  • switch statement
  • do-while loop
Program:
Program Part 1
Program Part 2
Program Output:
Program Output Part 1
Program Output Part 2
💡 Key Explanation

This activity teaches how to build a simple interactive Java program using control structures. The ATM system simulates real-life banking operations like checking balance, depositing, and withdrawing money. It helps you practice decision-making, looping, and structuring programs logically while enforcing rules like withdrawal limits.

Midterm Activity #4 - Student Payment System with Validation Counter

Download PDF
Grade: 30/30
â–¼
Program Requirements:
  1. Create a Java program named: StudentPaymentSystemLastName (Example: StudentPaymentSystemBedis)
  2. Ask the user to input:
    • Student Name
    • Student ID
    • Total Tuition Fee
  3. Display the menu:
===== PAYMENT MENU =====
  • 1. Pay Tuition
  • 2. Check Balance
  • 3. Apply Discount
  • 4. Exit
Program Rules
General Rules
  • Use switch statement to process menu options
  • Use do-while loop to repeat the program until Exit
  • Use nested if statements for validation
  • Use a counter variable to track number of transactions
Payment Rules
  1. Pay Tuition
    • Ask for payment amount
    • Validate:
      • If payment > remaining balance → display: Invalid Payment
      • Else → deduct from balance
    • Increment transaction counter
  2. Check Balance
    • Display remaining balance
    • Increment transaction counter
  3. Apply Discount
    • Ask user if they are:
      • Regular Student
      • Scholar
    • Conditions:
      • If Scholar → 20% discount
      • If Regular → no discount
      • Discount applies only once
  4. Exit
    • Display:
      • Student Name
      • Total Transactions
      • Final Balance
    • End program
Additional Conditions
  • Prevent negative balance
  • Prevent multiple discount applications
  • Show message: No remaining balance if fully paid
Program:
Program Part 1
Program Part 2
Program Part 3
Program Output:
Output (1)
Program Output 1
Output (2)
Program Output 2.1
Program Output 2.2
Output (3)
Program Output 3.1
Program Output 3.2
💡 Key Explanation

This activity simulates a student payment system where a user enters their details and manages their tuition balance. The user can make payments, check how much is left, and apply a discount if eligible. The program ensures payments are valid by preventing overpayment and negative balances, and it only allows the discount to be applied once. It also keeps track of how many transactions are made. At the end, it shows the student’s name, total transactions, and final remaining balance.

Midterm Activity #5 - Personal Expense Tracker

Download PDF
Grade: 30/30
â–¼
Instructions:
  1. Create a Java program named ExpenseTrackerLastName.
  2. Implement the following methods:
    • A void method that displays the program title.
    • A non-void method that calculates the total expenses using three values:
      • food
      • transportation
      • other expenses
    • A non-void method that checks if the total expense exceeds a budget and returns a message.
    • A void method that displays the total expense and the budget status.
  3. In the main method:
    • Call all the methods you created.
    • Display the final output clearly.
  4. Use appropriate method names, parameters, and return types.
  5. Add at least TWO enhancements:
    • Accept user input
    • Add another expense category
    • Compute remaining budget
    • Display a personalized message
Program:
Program Part 1
Program Part 2
Program Output:
Program Output Part 1
Program Output Part 2
💡 Key Explanation

This activity simulates a simple expense tracker using methods in Java. The program separates tasks like displaying the title, computing total expenses, and checking if the budget is exceeded. It takes user input for different expenses, calculates the total, and compares it to the budget to determine the status and finally, show the summary of expenses.

Midterm Exam

Results Pending

This is the examination completed for the midterm period.

💡 Exam Summary

The midterm exam covered all the key topics discussed throughout the lessons and tested my ability to analyze and trace code. It also helped strengthen my understanding of how all the concepts are connected and how they are applied together.