wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

PROF. BUCALING'S FINAL EXAM - Fundamentals of Programming

Total questions: 50

Worksheet time: 30mins

Name
Class
Date
1.

You're organizing a birthday party and need to store the ages of 5 guests. Your friend suggests creating variables: guest1Age, guest2Age, guest3Age, guest4Age, guest5Age. What's the MAIN problem with this approach when you suddenly have 50 guests?

a)

A) It uses too much memory

b)

B) You'd need to write 50 separate variable declarations

c)

C) The ages won't be stored properly

d)

D) It's impossible to do calculations

2.

You're building a library system. Books are stored in a shelf where the first book is at position 0, second at position 1, and so on. If a shelf has 10 books, what happens when someone asks for the book at position 10?

a)

A) Returns the last book

b)

B) Returns the first book

c)

C) Returns null

d)

D) System crashes with an error

3.

A teacher wants to check if a student's name exists in a class list of 30 students. What information do you need to access ALL student names efficiently?

a)

The first student's name only

b)

The array name and a loop counter

c)

The last index number

d)

The teacher's permission

4.

You're creating a seating chart for a movie theater. Each row has seats, and there are multiple rows. What type of storage structure represents this BEST?

4 lines
5.

A restaurant has a reservation system. If they declare String[] reservations = new String[20]; but only 15 people make reservations, what can you say about the array?

a)

It will automatically shrink to size 15

b)

It stays size 20 with 5 empty slots

c)

It will cause an error

d)

It will delete the last 5 reservations

6.

You're tracking daily temperatures for a week. You store them as int[] temps = {32, 30, 28, 35, 33, 31, 29};. How do you find out how many days of data you have WITHOUT counting manually?

a)

temps.size()

b)

temps.length

c)

temps.count()

d)

temps.length()

7.

A game developer stores player scores in an array. To display the third player's score, which index should they access?

a)

A) 3

b)

B) 2

c)

C) 1

d)

D) 0

8.

You're making a contact list app. Users can add contacts, but after declaring String[] contacts = new String[100];, a user wants to add a 101st contact. What's true?

a)

The array automatically expands

b)

The last contact gets overwritten

c)

You need to create a new larger array

d)

The 101st contact goes to index 100

9.

A chess board is 8x8. How would you properly declare an array to represent all squares?

a)

int chess = new int[8,8];

b)

int[][] chess = new int[8][8];

c)

int[] chess = new int[64];

d)

int chess[8][8];

10.

You store exam scores: int[] scores = {85, 90, 78, 92, 88};. To calculate the class average, you need to add all scores and divide by what value?

a)

A) 5

b)

B) 4

c)

C) scores.length

d)

D) scores.size

11.

A parking lot has 3 floors, each floor has 20 spots. You declare int[][] parking = new int[3][20];. To mark the 5th spot on the 2nd floor as occupied, what's the correct way?

a)

parking[2][5] = 1;

b)

parking[1][4] = 1;

c)

parking[5][2] = 1;

d)

parking[2][4] = 1;

12.

You're storing student grades in double[] grades = new double[25];. A student asks to check their grade, and you accidentally access grades[25]. What happens?

a)

Returns 0

b)

Returns the last grade

c)

Array-index-out-of-bounds error

d)

Returns null

13.

A store inventory system tracks items in different categories. Category A has 10 items, Category B has 15 items, Category C has 8 items. What's the most efficient declaration?

a)

Three separate arrays of different sizes

b)

One multidimensional array with equal dimensions

c)

One long array with 33 items

d)

Different arrays for each category

14.

You initialize String[] names = {"Ana", "Ben", "Cat"}; and later try names[1] = "Bob"; What happens?

a)

Error because arrays are immutable

b)

"Ben" changes to "Bob" successfully

c)

Both "Ben" and "Bob" are stored

d)

The array rejects the change

15.

A fitness app tracks workouts for 7 days. Each day has 3 metrics (duration, calories, distance). How many total values can be stored in int[][] fitness = new int[7][3];?

a)

7

b)

10

c)

21

d)

3

16.

You're designing a banking system. A bank account has a balance, account number, and can perform deposits/withdrawals. What programming concept represents "performing deposits"?

a)

State

b)

Behavior

c)

Identity

d)

Class

17.

A car manufacturing company needs to produce 1000 cars with the same specifications but different colors and serial numbers. What should they create FIRST?

a)

1000 separate car designs

b)

A blueprint (class) for the car

c)

Individual car objects

d)

A method to paint cars

18.

You create a Student class with a method calculateGPA(). You want to use this method for 50 different students. What's the MAIN advantage?

a)

Each student has unique GPA

b)

You write the calculation logic only once

c)

Students can share grades

d)

The method runs faster

19.

A social media app has a "Like" button. Every user can like posts. The action of clicking "Like" is a method that increases a counter. What makes this method useful across millions of users?

a)

It's predefined in Java

b)

Each user has a different like button

c)

Reusability - same method for all users

d)

It's synchronized

20.

You're creating a Calculator class. You want a method to add two numbers and give you the result. What should you replace void with if the method is: void add(int a, int b)?

a)

static

b)

int

21.

A food delivery app has restaurants. Each restaurant has a name, address, rating, and can accept orders. What represents the "identity" of a restaurant?

a)

The name of the restaurant

b)

The address

c)

The unique reference that distinguishes it from others

d)

The rating

22.

You write a method: public void printReceipt(String item, double price). When calling this method, what are "Burger" and 5.99?

a)

Parameters

b)

Arguments

c)

Variables

d)

Objects

23.

A hospital system has a Patient class. Creating a new patient record means you need to:

a)

Modify the Patient class

b)

Create an instance of the Patient class

c)

Use a predefined method

d)

Declare a new class

24.

You create a method to check if a student passed: public boolean isPassed(int score). It should return true if score >= 75, false otherwise. What keyword must be inside this method?

a)

void

b)

return

c)

static

d)

break

25.

A gaming company uses the same playSound() method for all sound effects. One day they fix a bug in this method. What happens?

a)

Only new sounds are fixed

b)

All sound effects are fixed everywhere

c)

They need to fix each sound separately

d)

Nothing changes

26.

You have a Rectangle class with length and width values. These values represent the:

a)

Area of the rectangle

b)

Perimeter of the rectangle

c)

Dimensions of the rectangle

d)

Diagonal of the rectangle

27.

A pizza ordering system has a method orderPizza(String size, String topping, int quantity). You call it as orderPizza("Large", "Pepperoni", 2);. What does String size represent?

a)

A) Argument

b)

B) Parameter

c)

C) Object

d)

D) Return value

28.

You need to use Math.sqrt() to calculate square roots in your program. This method is:

a)

User-defined

b)

Predefined

c)

Custom-made

d)

Invalid

29.

A login system checks usernames. The method is public void checkUser(String username). Users complain they don't know if login succeeded. What's wrong?

a)

A) Missing parameters

b)

B) Method doesn't return anything useful

c)

C) Wrong data type

d)

D) Needs more arguments

30.

You're building a school system with classes for Teacher, Student, and Classroom. Each class represents a:

a)

Method

b)

Object

c)

Template for creating objects

d)

Instance

31.

A chat application stores messages. Creating messages as String msg1 = "Hello"; and String msg2 = "Hello"; means:

4 lines
32.

You're building a text editor. Users type long documents that need constant editing (adding, removing, replacing text). What should you use?

a)

String

b)

StringBuffer

c)

StringBuilder

d)

char[]

33.

An e-commerce site shows product reviews. One review says "This product is bad" and you want to change "bad" to "good". You need to replace characters at specific positions. What method does this?

a)

concat()

b)

replace()

c)

substring()

d)

split()

34.

A messenger app shows typing indicators by adding dots: "Typing" → "Typing." → "Typing.." → "Typing...". What StringBuilder method efficiently adds these dots?

a)

insert()

b)

append()

c)

concat()

d)

add()

35.

You create: String s1 = "Java"; and String s2 = new String("Java");. What's the difference?

a)

No difference, both are identical

b)

s1 reuses existing literal, s2 creates a new object

c)

s2 is faster

d)

s1 creates two objects

36.

A password validator needs to check if a password meets requirements by examining each character. What method gets the character at a specific position?

a)

getChar()

b)

charAt()

c)

characterAt()

d)

get()

37.

A social media username must be unique. The system needs to reverse the username for a special display feature. If the username is stored in a StringBuilder, what method reverses it?

a)

reverse()

b)

backwards()

c)

flip()

d)

invert()

38.

You're creating a URL shortener. The original URL is https://example.com/very/long/path and you only need /very/long/path. What extracts this portion?

a)

split()

b)

substring()

c)

replace()

d)

charAt()

39.

A text message app has a character limit. Before sending, you need to count characters in the message. What method does this?

a)

size()

b)

length()

c)

count()

d)

capacity()

40.

You're building a search feature. When storing millions of search queries, you want to save memory by reusing identical strings. How should you create these strings?

a)

Always use new String()

b)

Use String literals

c)

Use StringBuilder for each

d)

Use char arrays

41.

You created a program to calculate student grades. Teachers run it as java GradeCalc 85 90 78. What stores these three numbers?

a)

Three separate int variables

b)

The args array in main method

c)

A Scanner object

d)

System.in

42.

A calculator program runs as java Calculator 15 7. You want to add these numbers, but args[0] + args[1] gives “157” instead of 22. Why?

a)

Wrong operator

b)

args stores everything as String

c)

Calculator is broken

d)

Need to use Scanner

43.

An ATM system has a function to calculate interest. The formula never changes: same input always produces same output. What should the Deterministic property be?

a)

FALSE

b)

TRUE

c)

MAYBE

d)

NULL

44.

You run: java Program Hello 123 World 456. What is args.length?

a)

A) 3

b)

B) 4

c)

C) 5

d)

D) 8

45.

A company needs a custom function to calculate employee bonuses. They can't find this in Java's built-in methods. What should they create?

a)

Predefined Function

b)

User Defined Function

c)

System Function

d)

Static Method

46.

Your program runs as java Test 42.5. To convert this to a decimal number for calculations, what should you use?

a)

Integer.parseInt()

b)

Float.parseFloat()

c)

Double.parseDouble()

d)

String.toDouble()

47.

A temperature converter accepts Celsius from command line: java TempConverter 25. Inside the program, args[0] is:

a)

int 25

b)

double 25.0

c)

String "25"

48.

You create a function calculateTax that must process data from a database source. The function MUST execute on that source server, not locally. What pushdown option?

a)

ALLOWED

b)

NEVER

c)

REQUIRED

d)

OPTIONAL

49.

A function name in your program is public void 123Start(). What's wrong?

a)

Nothing, it's valid

b)

Function names can't start with numbers

c)

Missing return type

d)

void is incorrect

50.

You run a quiz program: java Quiz 10 20 30 40. To access the third number, what's the correct code?

a)

args[3]

b)

args[2]

c)

args.get(3)

d)

args.get(2)