0% found this document useful (0 votes)
3 views14 pages

Practice Questions For Cos 261

The document contains a compilation of objective questions related to Java programming, covering topics such as Java features, data types, control structures, and object-oriented programming concepts. Each question includes multiple-choice answers, testing knowledge on Java syntax, commands, and programming principles. The questions are designed to assess understanding of Java fundamentals and software development processes.

Uploaded by

udochukwutiago84
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views14 pages

Practice Questions For Cos 261

The document contains a compilation of objective questions related to Java programming, covering topics such as Java features, data types, control structures, and object-oriented programming concepts. Each question includes multiple-choice answers, testing knowledge on Java syntax, commands, and programming principles. The questions are designed to assess understanding of Java fundamentals and software development processes.

Uploaded by

udochukwutiago84
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 14

Here is a compilation of all the objective questions generated based on the

provided COS 261 Summary:


1. Which of the following is NOT a feature of Java?

A) Portability

B) Security

C) Procedural Programming

D) Object-Oriented Programming

2. What does the abbreviation JVM stand for?

A) Java Virtual Machine

B) Java Verified Module

C) Joint Venture Manager

D) JavaScript Validation Method

3. Which of these is a primitive data type in Java?

A) String

B) Array

C) int

D) Class

4. Which operator is used to assign a value to a variable in Java?

A) ==

B) =

C) !=

D) &&

5. What is the output of a compiled Java program, typically having a .class


extension?

A) Source code
B) Bytecode

C) Executable file

D) Machine code

6. Which of the following is a characteristic of Object-Oriented Programming


(OOP)?

A) Linear Execution

B) Inheritance

C) Global Variables

D) Static Typing only

7. According to the document, what is an algorithm?

A) A type of computer virus

B) A logical sequence of steps used to solve a particular problem

C) A programming language

D) A hardware component

8. Which of the following is a control structure used for executing a block of


code multiple times when the number of executions is known?

A) While loop

B) If/else statement

C) For loop

D) Switch statement

9. In an array, what is the index number of the first item?

A) 1

B) 0

C) -1
D) Any integer

10. Which command is used in the command prompt to compile a Java file?

A) java filename

B) javac filename.java

C) run filename

D) execute filename.class

11. What is the primary purpose of System.in in Java?

A) To print errors to the screen

B) To accept user input

C) To print output to the screen

D) To display system information

12. Which of the following IDEs is mentioned in the summary?

A) Visual Basic

B) NetBeans

C) Xcode

D) Android Studio

13. What is the difference between print() and println() methods in Java?

A) print() adds a new line after output, println() does not.

B) println() adds a new line after output, print() does not.

C) print() is for integers, println() is for strings.

D) They are identical in functionality.

14. What does the term "Variables" refer to in Java?

A) Names given to classes


B) Reserved words with specific meanings

C) A container/memory location that holds data

D) The output of a compiled Java program

15. Which of the following is NOT a type of error mentioned in the debugging
section?

A) Syntax errors

B) Logical errors

C) Hardware errors

D) Runtime errors

16. Which data structure stores elements in a tabular form with rows and
columns?

A) Linked List

B) Stack

C) Two-Dimensional Array

D) Queue

17. What is a "Keyword" in Java?

A) A name given to a variable

B) A user-defined function

C) A reserved word with specific meaning

D) A type of operator

18. In Java, what is the purpose of javac?

A) To interpret Java bytecodes

B) To run a Java program

C) To compile a Java file


D) To debug a Java program

19. Which of the following describes a Stack data structure?

A) First-In-First-Out (FIFO)

B) Last-In-First-Out (LIFO)

C) Elements are accessed by index

D) Nodes are connected by edges

20. When choosing a data structure, which of these factors should be


considered?

A) Favorite color

B) Data size and complexity

C) Social media trends

D) Current weather conditions

21. What is the name given to variables, classes, and methods/functions in


Java?

A) Keywords

B) Literals

C) Identifiers

D) Operators

22. Which type of loop is used when the number of times you want to execute
isn't known?

A) For loop

B) Do-while loop

C) While loop

D) Enhanced for loop

23. What is "Polymorphism" in the context of OOP characteristics?


A) The process of hiding implementation details

B) The ability of an object to take on many forms

C) The mechanism of creating new classes from existing ones

D) The technique of repeating a method execution

24. What is the approximate range for an int data type in Java, according to
the summary?

A) -128 to 127

B) -32768 to 32767

C) -2 million to +2 million

D) -10^18 to +10^18

25. Which operator is used for comparison, such as checking if two values are
equal?

A) =

B) !=

C) &&

D) +

26. What does "Portability" mean as a feature of Java?

A) It can only run on specific platforms.

B) It is platform independent.

C) It requires specific hardware to run.

D) It is difficult to move between systems.

27. What is the first step in the Software Development Process as listed in the
summary?

A) Implementation

B) Design
C) Analysis

D) Testing

28. Which of the following is a non-linear data structure?

A) Array

B) Linked List

C) Queue

D) Trees

29. How is a Scanner class typically used in Java, according to the summary?

A) To print errors

B) To accept user input

C) To compile code

D) To display output

30. What is the term for a technique used to repeat the execution of a part of a
program by making the method call itself?

A) Iteration

B) Debugging

C) Recursion

D) Encapsulation

31. Which of the following is an arithmetic operator?

A) ==

B) %

C) !=

D) &&

32. What is the main benefit of OOP mentioned in the summary?


A) It makes code execution faster.

B) It makes code reusable.

C) It reduces memory consumption.

D) It simplifies hardware interaction.

33. How do you save a Java text file before compiling?

A) With a .txt extension

B) With a .doc extension

C) With a .java extension

D) With a .class extension

34. What is System.err primarily used for?

A) Printing standard output

B) Accepting user input

C) Printing errors to the screen, often in red text

D) Storing data temporarily

35. Which data structure follows the Last-In-First-Out (LIFO) principle?

A) Queue

B) Linked List

C) Stack

D) Array

36. What is the role of java command in the command prompt?

A) To compile a Java file

B) To interpret Java bytecodes

C) To create a new Java project


D) To debug syntax errors

37. What does API stand for?

A) Advanced Programming Interface

B) Application Process Integration

C) Application Programming Interface

D) Automated Program Instruction

38. Which type of array stores elements in a sequence of items of the same
data type?

A) Two-Dimensional Array

B) Dynamic Array

C) Single Array (often just called Array)

D) Jagged Array

39. What is "Debugging"?

A) Writing new code from scratch

B) A way of removing bugs from codes using a set of tools

C) Converting code to bytecode

D) Planning the software design

40. Which of the following is a type of relational/comparison operator?

A) +

B) =

C) !=

D) &&

41. What is the approximate range for a byte data type in Java?

A) -10^18
B) -3.4^38

C) -128 to 127

D) -1.7^308

42. Which data structure is described as a dynamic collection of elements,


where each element points to the next element?

A) Array

B) Linked List

C) Hash Table

D) Tree

43. What is the process of hiding the internal implementation details and
showing only the necessary functionalities called in OOP?

A) Inheritance

B) Polymorphism

C) Encapsulation

D) Message passing

44. Which type of operator is used with boolean expressions?

A) Arithmetic operators

B) Relational operators

C) Logical operators

D) Assignment operators

45. What is the purpose of JDK?

A) Java Development Kit

B) Java Debugging Kernel

C) Java Document Kit


D) Java Deployment Key

46. Which of the following is NOT a control structure mentioned in the


summary?

A) If/else statements

B) Switch statements

C) GoTo statements

D) Looping

47. What is a "Graph" in terms of data structures?

A) A collection of unique elements

B) A specialized tree-based structure

C) A non-linear data structure where nodes are connected by edges

D) A collection of elements of the same data type stored as a sequence

48. What is the final stage of the Software Development Process listed in the
summary?

A) Analysis

B) Design

C) Implementation

D) Testing

49. When would you use a do-while loop?

A) When the number of times you want to execute is known.

B) When the number of times you want to execute isn't known.

C) It executes the code once then acts like a while loop.

D) It is only used for infinite loops.

50. Which of the following is an example of a capitalized keyword (class) in


Java programs, as noted in the summary?
A) int

B) char

C) System

D) if

51. What is "Garbage collection" in the context of OOP characteristics?

A) A process of collecting user input.

B) Automatic memory management in Java.

C) A method for compiling code.

D) A way to organize data in arrays.

52. What is an "Index" in an array?

A) The value of an item.

B) The data type of an item.

C) The position number of an item.

D) The size of the array.

53. Which of these is a disadvantage of OOP mentioned in the summary?

A) It is less secure.

B) It is large in size and takes more effort.

C) It makes code less reusable.

D) It is not platform independent.

54. Which Java command is used to interpret Java bytecodes from the
command prompt?

A) javac

B) java

C) run
D) compile

55. What does GUI stand for?

A) General User Interface

B) Graphic User Instruction

C) Graphic User Interface

D) Global User Interaction

56. What is Recursion?

A) A type of loop for unknown iterations.

B) A technique to repeat execution by a method calling itself.

C) A method of debugging code.

D) A way to handle errors in a program.

57. According to the summary, which of the following is a way of developing a


Java program?

A) By only using a compiler.

B) By using a text editor and running it on the command prompt.

C) By writing directly in machine code.

D) By using only a web browser.

58. What is the approximate range for a long data type in Java?

A) -+128

B) -32768

C) -2 million

D) -10^18

59. What kind of data structure is a Heap?

A) A linear data structure that stores elements sequentially.


B) A specialized tree-based data structure.

C) A collection of unique elements.

D) A data structure that maps keys to values using a hash function.

60. Which command should be used to display output and move to the next
line in Java?

A) System.out.print()

B) System.out.println()

C) System.in.read()

D) System.err.print()

You might also like