IB Computer Exam Practice
Table of Contents
IB computer exam practice questions are presented along with their answers.
Questions
What is a method in Java?
A) A type of loop
B) A way to define and reuse a block of code
C) A conditional statement
D) A data structure
When defining a method, what does the return type specify?
A) The input parameters of the method
B) The name of the method
C) The data type of the value returned by the method
D) The visibility of the method
What is the purpose of preconditions in method design?
A) To specify the conditions under which a method should be called
B) To specify the conditions that must be true after a method executes
C) To specify the conditions under which a method can be called
D) To specify the conditions that should be true before a method executes
What is the purpose of postconditions in method design?
A) To specify the conditions under which a method should be called
B) To specify the conditions that should be true before a method executes
C) To specify the conditions that must be true after a method executes
D) To specify the conditions under which a method can be called
Which of the following is a program entry point in Java?
A) The main() method
B) A constructor
C) A getter method
D) A setter method
What is control flow in Java?
A) The syntax used to define a method
B) The order in which statements are executed
C) The way in which data is stored in memory
D) The way in which Java interacts with the operating system
What is looping in Java?
A) A way to create objects
B) A way to execute code based on a certain condition
C) A way to repeat a block of code until a certain condition is met
D) A way to define variables
Which of the following is a conditional statement in Java?
A) for loop
B) while loop
C) switch statement
D) if statement
What is the purpose of classes in Java?
A) To store data
B) To define methods
C) To define objects with attributes and behaviors
D) To define loops and conditionals
What is the purpose of commenting code in Java?
A) To explain how the code works
B) To make the code more efficient
C) To prevent others from reading the code
D) To make the code more difficult to understand
Which of the following is a method for encoding digital data?
A) JPEG
B) ASCII
C) MP3
D) PDF
What is the binary representation of the decimal number 18?
A) 10010
B) 11000
C) 11110
D) 10000
Which number system is commonly used in computer science?
A) Decimal
B) Binary
C) Octal
D) Hexadecimal
What is the hexadecimal representation of the binary number 11110010?
A) EA
B) E6
C) F2
D) F4
How do computers manipulate images at the pixel level?
A) By changing the resolution of the image
B) By changing the color of the entire image
C) By changing the brightness of the entire image
D) By changing the color and brightness of individual pixels
Which of the following is an advantage of using hexadecimal number system?
A) Hexadecimal numbers are easier to convert to binary than decimal numbers
B) Hexadecimal numbers are easier to read and remember than binary numbers
C) Hexadecimal numbers are easier to perform arithmetic operations than decimal numbers
D) Hexadecimal numbers are easier to represent negative numbers than binary numbers
What is the process of converting data from one format to another called?
A) Decoding
B) Transcoding
C) Encoding
D) Compression
Which of the following is a commonly used image file format?
A) MP3
B) PDF
C) JPEG
D) TXT
What is the purpose of representing data in binary form in computers?
A) To reduce the storage space required for data
B) To speed up data processing
C) To enable the transmission of data over networks
D) All of the above
What is the internet?
A) A global network of computers
B) A type of computer hardware
C) A software program for browsing the web
D) A type of computer virus
Which protocol is commonly used for transmitting web data over the internet?
A) HTTP
B) FTP
C) SMTP
D) Telnet
Which numbering system is commonly used in computer science?
A) Decimal
B) Binary
C) Octal
D) Hexadecimal
Which of the following is a valid binary number?
A) 1020
B) 1011
C) 8F
D) 57
Which of the following is an example of internet hardware?
A) Router
B) Email client
C) Web browser
D) Text editor
Which type of cable is commonly used for connecting devices to the internet?
A) Coaxial cable
B) Fiber optic cable
C) Ethernet cable
D) USB cable
Which of the following is used to uniquely identify a device on the internet?
A) Domain name
B) URL
C) MAC address
D) IP address
Which version of the IP protocol is commonly used on the internet?
A) IP version 4
B) IP version 6
C) IP version 10
D) IP version X
What is the purpose of the Domain Name System (DNS)?
A) To encrypt internet traffic
B) To block access to certain websites
C) To manage email accounts
D) To translate domain names into IP addresses
Which type of DNS record maps a domain name to an IP address?
A) A record
B) MX record
C) CNAME record
D) PTR record
What is a packet?
A) A type of computer hardware
B) A software program for browsing the web
C) A unit of data transmitted over a network
D) A type of computer virus
Which protocol is commonly used for transmitting email over the internet?
A) HTTP
B) FTP
C) SMTP
D) Telnet
What is the primary goal of cybersecurity?
A) To prevent any unauthorized access to information
B) To provide unrestricted access to information
C) To secure information without restricting access
D) To provide unrestricted access to information but with security controls in place
Which of the following is an example of a common cyber attack?
A) Denial of Service (DoS)
B) Password sharing
C) Backing up important files
D) Updating software regularly
What is phishing?
A) A type of malware that spreads through a network
B) A type of cyber attack that targets specific individuals or groups
C) A type of cyber attack that involves guessing passwords
D) A type of cyber attack that manipulates users to provide sensitive information
What is encryption?
A) A process of converting plain text into code to secure information
B) A process of converting code into plain text to access information
C) A process of converting information into binary code
D) A process of converting information into compressed format
What is a firewall?
A) A physical barrier that prevents unauthorized access to a network
B) A software program that blocks unauthorized access to a network
C) A software program that monitors network traffic and identifies potential threats
D) A software program that encrypts data to secure it during transmission
What is two-factor authentication?
A) A security method that requires two passwords to access sensitive information
B) A security method that involves using a physical token to authenticate a user
C) A security method that involves verifying a user's identity through two different means
D) A security method that uses a biometric scan to authenticate a user
Which of the following is NOT an example of a cybersecurity threat?
A) Malware
B) Viruses
C) Backups
D) Ransomware
What is a VPN?
A) A software program that encrypts data to secure it during transmission
B) A physical barrier that prevents unauthorized access to a network
C) A software program that blocks unauthorized access to a network
D) A software program that allows users to connect to a private network over the internet
Which of the following is a good cybersecurity practice?
A) Using the same password for multiple accounts
B) Updating software regularly
C) Clicking on links in emails from unknown senders
D) Ignoring security warnings from software programs
What is a DDoS attack?
A) A type of cyber attack that manipulates users to provide sensitive information
B) A type of cyber attack that targets specific individuals or groups
C) A type of cyber attack that involves flooding a server with traffic to make it unavailable
D) A type of cyber attack that involves stealing confidential information
Which of the following is a potential negative impact of the internet on society?
A) Increased cyberbullying and online harassment
B) Increased access to information
C) Increased social connectedness
D) Increased opportunities for education and learning
Which of the following is an example of how the internet has impacted the job market?
A) Increased demand for manual labor jobs
B) Decreased demand for tech-related jobs
C) Increased demand for remote work and telecommuting
D) Decreased demand for jobs in the service industry
What is the digital divide?
A) The gap between those who have access to the internet and those who do not
B) The difference in internet speeds between urban and rural areas
C) The gap in income between those who work in tech-related industries and those who do not
D) The difference in internet usage between different age groups
Which of the following is a potential positive impact of the internet on education?
A) Increased opportunities for cheating and academic dishonesty
B) Increased access to educational resources and information
C) Decreased interest in traditional forms of learning, such as classroom lectures
D) Increased emphasis on rote memorization and standardized testing
Which of the following is a potential positive impact of the internet on the economy?
A) Increased competition and market transparency
B) Reduced need for skilled labor
C) Increased inflation rates
D) Decreased access to global markets
What is the primary purpose of a CPU in a computer system?
A) To store data
B) To display graphics
C) To run applications
D) To process data
What is the purpose of a device driver?
A) To control the computer's hardware components
B) To create and edit documents
C) To connect to the internet
D) To display graphics on the screen
What is the purpose of a motherboard in a computer system?
A) To store data
B) To display graphics
C) To connect to the internet
D) To provide communication between components
Why is Java a popular programming language?
A) It is platform-independent
B) It is easy to learn and use
C) It has a large and active community
D) All of the above
Which of the following is a correct way to declare a variable of type String?
A) String name = "John";
B) String name = John;
C) string name = "John";
D) None of the above
What is the value of the expression "5 / 2" in Java?
A) 2.5
B) 2
C) 2.0
D) 2.5f
Which of the following is a valid data type in Java?
A) int
B) boolean
C) float
D) All of the above
What is the purpose of the Scanner class in Java?
A) To read user input from the console
B) To write output to the console
C) To perform mathematical calculations
D) To create graphical user interfaces
Why is programming important?
A) To improve problem-solving skills
B) To develop analytical and logical thinking
C) To automate repetitive tasks
D) All of the above
What is the range of values that can be stored in a byte variable in Java?
A) -128 to 127
B) 0 to 255
C) -32768 to 32767
D) -2147483648 to 2147483647
Which of the following data types can hold decimal numbers in Java?
A) int
B) double
C) char
D) boolean
What is the output of the following Java code?
String s = "Hello";
System.out.println(s.substring(0, 3));
A) Hel
B) ello
C) llo
D) Error
Which of the following statements is true about object-oriented programming (OOP)?
A) It focuses on procedures and functions.
B) It uses a procedural approach to programming.
C) It involves the use of objects and classes.
D) It is an outdated approach to programming.
What is the output of the following code snippet?
int x = 7;
double y = 3.0;
System.out.println(x / y);
A) 2.333333
B) 2
C) 2.0
D) None of the above
Which of the following is an example of a non-primitive data type in Java?
A) int
B) char
C) boolean
D) String
What is the output of the following Java code?
int[] arr = {1, 2, 3};
for(int i = 0; i < arr.length; i++){
System.out.print(arr[i] + " ");
}
A) 1 2 3
B) [1, 2, 3]
C) {1, 2, 3}
D) Error
What is the output of the following Java code?
String s1 = "Hello";
String s2 = "World";
System.out.println(s1 + " " + s2);
A) HelloWorld
B) Hello World
C) Hello\nWorld
D) Error
What is the output of the following Java code?
int[][] arr = {{1, 2}, {3, 4}};
System.out.println(arr[1][0]);
A) 1
B) 2
C) 3
D) 4
What is the output of the following Java code?
public class Main {
public static void main(String[] args) {
int x = 5;
System.out.println(x > 2 ? "Yes" : "No");
}
}
A) Yes
B) No
C) 5
D) Error
What is the output of the following Java code?
int x = 5;
int y = 3;
if(x > y){
System.out.println("x is greater than y.");
} else if(x == y){
System.out.println("x is equal to y.");
} else {
System.out.println("y is greater than x.");
}
A) x is equal to y.
B) x is greater than y.
C) y is greater than x.
D) Error
Which of the following is a correct statement about objects?
A) Objects can be created without a class.
B) Objects are instances of methods.
C) Objects are instances of classes.
D) Objects are not used in Java programming.
What is the process of creating an object called in Java?
A) Initialization
B) Declaration
C) Instantiation
D) Assignment
Which keyword is used to call a method in Java?
A) Call
B) Invoke
C) Use
D) Perform
What is the result of the following concatenation in Java: "Hello" + 5 + 6?
A) "Hello56"
B) "Hello11"
C) "Hello5 6"
D) "Hello"
Which of the following is a String method in Java?
A) length()
B) max()
C) abs()
D) sqrt()
Which class in Java contains mathematical operations such as sin, cos, and tan?
A) Scanner
B) Random
C) String
D) Math
Which of the following is NOT a wrapper class in Java?
A) String
B) Integer
C) Double
D) Boolean
Which of the following is a valid Boolean expression?
A) 5 + 2 > 8
B) "hello" == "world"
C) true || false
D) all of the above
What is the purpose of if statements in programming?
A) To declare variables
B) To create loops
C) To print output to the console
D) To control program flow based on a condition
Which of the following is the correct syntax for an if statement in Java?
A) if {condition} then {code block}
B) if (condition) {code block}
C) if [condition] {code block}
D) if /condition/ {code block}
What is the purpose of the else statement in programming?
A) To declare variables
B) To create loops
C) To execute code if the condition in the if statement is false
D) To print output to the console
Which of the following is an equivalent Boolean expression to !(x > 5 || y < 3)?
A) x <= 5 && y >= 3
B) x > 5 && y >= 3
C) x > 5 || y < 3
D) x <= 5 || y >= 3
Which of the following is the correct syntax for comparing two objects in Java?
A)) obj1 == obj2
B) obj1.equals(obj2)
C) obj1.compare(obj2)
D) obj1.compareTo(obj2)
Which loop structure is best suited when the number of iterations is unknown?
A) for loop
B) while loop
C) do-while loop
D) if-else loop
What is the output of the following code?
int count = 0;
while (count < 5) {
System.out.print(count + " ");
count++;
}
A) 0 1 2 3 4
B) 1 2 3 4 5
C) 0 1 2 3 4 5
D) 1 3 5 7 9
Which keyword is used in Java to refer to the current instance of a class?
A) class
B) object
C) this
D) super
Which of the following is a method that is used to change the value of an instance variable?
A) Constructor
B) Accessor Method
C) Mutator Method
D) Static Method
Which of the following is a variable that is shared by all instances of a class?
A) Instance Variable
B) Local Variable
C) Parameter Variable
D) Static Variable
Which keyword is used to access a static variable or method?
A) this
B) super
C) final
D) static
Which of the following is a section of code that is only executed when a new instance of a class is created?
A) Constructor
B) Accessor Method
C) Mutator Method
D) Static Method
What is an array in Java?
A) A type of object
B) A collection of variables of the same data type
C) A loop structure
D) A conditional statement
What is the correct syntax to create an array of integers in Java?
A) int[] array = new int();
B) int array = new int[];
C) int[] array = new int[5];
D) int array = {1, 2, 3, 4, 5};
How do you access an element in an array in Java?
A) By using the array name followed by the index enclosed in square brackets
B) By using the index followed by the array name enclosed in square brackets
C) By using the element name followed by the array name enclosed in square brackets
D) By using the array name followed by the element name enclosed in square brackets
Which loop structure is commonly used for traversing arrays in Java?
A) while loop
B) do-while loop
C) for loop
D) switch statement
What is an algorithm?
A) A mathematical formula
B) A sequence of instructions to solve a problem
C) A variable declaration
D) A loop structure
Which of the following is a valid method of adding an element to an ArrayList?
A) arrayList.addLast(5);
B) arrayList.push(5);
C) arrayList.insert(5);
D) arrayList.add(5);
How can you remove an element at a specific index from an ArrayList?
A) arrayList.remove(index);
B) arrayList.delete(index);
C) arrayList.removeElementAt(index);
D) arrayList.erase(index);
What is the purpose of the enhanced for loop in ArrayLists?
A) To add elements to the ArrayList
B) To remove elements from the ArrayList
C) To iterate through the ArrayList
D) To sort the elements in the ArrayList
What is the syntax for declaring a 2D array in Java?
A) int[] arr;
B) int arr[2][3];
C) int[][] arr;
D) int arr[][];
What is the syntax for traversing a 2D array using nested loops?
A) for (int i = 0; i < arr.length; i++) for (int j = 0; j < arr[i].length; j++)
B) for (int i = 0; i < arr.length; j++) for (int j = 0; j < arr[i].length; i++)
C) for (int i = 0; i < arr.length; i++) for (int j = 1; j <= arr[i].length; j++)
D) None of the above
Which keyword is used in Java to implement inheritance?
A) superclass
B) subclass
C) implements
D) extends
What is method overriding in Java?
A) Creating a new method in the subclass with the same name as a method in the superclass
B) Creating a new method in the superclass with the same name as a method in the subclass
C) Deleting a method in the superclass that is not needed in the subclass
D) Renaming a method in the subclass to avoid name conflicts with the superclass
What is polymorphism in Java?
A) The ability of an object to take on many forms
B) The ability of a subclass to override a method in the superclass
C) The ability of a superclass to call a method in the subclass
D) The ability of an object to be assigned to multiple variables of different types
What is recursion in Java?
A) A loop that repeats a set of instructions
B) A conditional statement that executes different blocks of code depending on a boolean expression
C) A data structure that stores elements of the same type
D) A method that calls itself
Which keyword is used in Java to indicate that a class cannot be subclassed?
A) abstract
B) static
C) final
D) none of the above
Answers
- B
- C
- D
- C
- A
- B
- C
- D
- C
- A
- B
- A
- B
- C
- D
- B
- C
- C
- D
- A
- A
- B
- B
- A
- C
- D
- A
- D
- A
- C
- C
- A
- A
- D
- A
- B
- C
- C
- D
- B
- C
- A
- C
- A
- B
- A
- D
- A
- D
- D
- A
- B
- D
- A
- D
- A
- B
- A
- C
- A
- D
- A
- B
- C
- A
- B
- C
- C
- B
- A
- A
- D
- A
- C
- D
- B
- C
- A
- B
- B
- A
- C
- C
- D
- D
- A
- B
- C
- A
- C
- B
- D
- A
- C
- C
- A
- D
- A
- A
- D
- C