IB Computer Exam Practice

Table of Contents

IB computer exam practice questions are presented along with their answers.

Questions


  1. 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

  2. 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

  3. 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

  4. 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

  5. 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

  6. 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

  7. 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

  8. Which of the following is a conditional statement in Java?

    A) for loop
    B) while loop
    C) switch statement
    D) if statement

  9. 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

  10. 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

  11. Which of the following is a method for encoding digital data?

    A) JPEG
    B) ASCII
    C) MP3
    D) PDF

  12. What is the binary representation of the decimal number 18?

    A) 10010
    B) 11000
    C) 11110
    D) 10000

  13. Which number system is commonly used in computer science?

    A) Decimal
    B) Binary
    C) Octal
    D) Hexadecimal

  14. What is the hexadecimal representation of the binary number 11110010?

    A) EA
    B) E6
    C) F2
    D) F4

  15. 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

  16. 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

  17. What is the process of converting data from one format to another called?

    A) Decoding
    B) Transcoding
    C) Encoding
    D) Compression

  18. Which of the following is a commonly used image file format?

    A) MP3
    B) PDF
    C) JPEG
    D) TXT

  19. 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

  20. 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

  21. Which protocol is commonly used for transmitting web data over the internet?

    A) HTTP
    B) FTP
    C) SMTP
    D) Telnet

  22. Which numbering system is commonly used in computer science?

    A) Decimal
    B) Binary
    C) Octal
    D) Hexadecimal

  23. Which of the following is a valid binary number?

    A) 1020
    B) 1011
    C) 8F
    D) 57

  24. Which of the following is an example of internet hardware?

    A) Router
    B) Email client
    C) Web browser
    D) Text editor

  25. 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

  26. 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

  27. 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

  28. 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

  29. 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

  30. 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

  31. Which protocol is commonly used for transmitting email over the internet?

    A) HTTP
    B) FTP
    C) SMTP
    D) Telnet

  32. 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

  33. 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

  34. 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

  35. 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

  36. 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

  37. 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

  38. Which of the following is NOT an example of a cybersecurity threat?

    A) Malware
    B) Viruses
    C) Backups
    D) Ransomware

  39. 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

  40. 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

  41. 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

  42. 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

  43. 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

  44. 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

  45. 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

  46. 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

  47. 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

  48. 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

  49. 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

  50. 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

  51. 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

  52. What is the value of the expression "5 / 2" in Java?

    A) 2.5
    B) 2
    C) 2.0
    D) 2.5f

  53. Which of the following is a valid data type in Java?

    A) int
    B) boolean
    C) float
    D) All of the above

  54. 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

  55. 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

  56. 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

  57. Which of the following data types can hold decimal numbers in Java?

    A) int
    B) double
    C) char
    D) boolean

  58. 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

  59. 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.

  60. 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

  61. Which of the following is an example of a non-primitive data type in Java?

    A) int
    B) char
    C) boolean
    D) String

  62. 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

  63. 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

  64. 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

  65. 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

  66. 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

  67. 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.

  68. What is the process of creating an object called in Java?

    A) Initialization
    B) Declaration
    C) Instantiation
    D) Assignment

  69. Which keyword is used to call a method in Java?

    A) Call
    B) Invoke
    C) Use
    D) Perform

  70. What is the result of the following concatenation in Java: "Hello" + 5 + 6?

    A) "Hello56"
    B) "Hello11"
    C) "Hello5 6"
    D) "Hello"

  71. Which of the following is a String method in Java?

    A) length()
    B) max()
    C) abs()
    D) sqrt()

  72. Which class in Java contains mathematical operations such as sin, cos, and tan?

    A) Scanner
    B) Random
    C) String
    D) Math

  73. Which of the following is NOT a wrapper class in Java?

    A) String
    B) Integer
    C) Double
    D) Boolean

  74. Which of the following is a valid Boolean expression?

    A) 5 + 2 > 8
    B) "hello" == "world"
    C) true || false
    D) all of the above

  75. 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

  76. 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}

  77. 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

  78. 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

  79. 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)

  80. 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

  81. 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

  82. Which keyword is used in Java to refer to the current instance of a class?

    A) class
    B) object
    C) this
    D) super

  83. 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

  84. 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

  85. Which keyword is used to access a static variable or method?

    A) this
    B) super
    C) final
    D) static

  86. 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

  87. 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

  88. 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};

  89. 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

  90. Which loop structure is commonly used for traversing arrays in Java?

    A) while loop
    B) do-while loop
    C) for loop
    D) switch statement

  91. 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

  92. 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);

  93. 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);

  94. 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

  95. 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[][];

  96. 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

  97. Which keyword is used in Java to implement inheritance?

    A) superclass
    B) subclass
    C) implements
    D) extends

  98. 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

  99. 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

  100. 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

  101. 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

  1. B
  2. C
  3. D
  4. C
  5. A
  6. B
  7. C
  8. D
  9. C
  10. A
  11. B
  12. A
  13. B
  14. C
  15. D
  16. B
  17. C
  18. C
  19. D
  20. A
  21. A
  22. B
  23. B
  24. A
  25. C
  26. D
  27. A
  28. D
  29. A
  30. C
  31. C
  32. A
  33. A
  34. D
  35. A
  36. B
  37. C
  38. C
  39. D
  40. B
  41. C
  42. A
  43. C
  44. A
  45. B
  46. A
  47. D
  48. A
  49. D
  50. D
  51. A
  52. B
  53. D
  54. A
  55. D
  56. A
  57. B
  58. A
  59. C
  60. A
  61. D
  62. A
  63. B
  64. C
  65. A
  66. B
  67. C
  68. C
  69. B
  70. A
  71. A
  72. D
  73. A
  74. C
  75. D
  76. B
  77. C
  78. A
  79. B
  80. B
  81. A
  82. C
  83. C
  84. D
  85. D
  86. A
  87. B
  88. C
  89. A
  90. C
  91. B
  92. D
  93. A
  94. C
  95. C
  96. A
  97. D
  98. A
  99. A
  100. D
  101. C