Practice Questions For Cos 261
Practice Questions For Cos 261
A) Portability
B) Security
C) Procedural Programming
D) Object-Oriented Programming
A) String
B) Array
C) int
D) Class
A) ==
B) =
C) !=
D) &&
A) Source code
B) Bytecode
C) Executable file
D) Machine code
A) Linear Execution
B) Inheritance
C) Global Variables
C) A programming language
D) A hardware component
A) While loop
B) If/else statement
C) For loop
D) Switch statement
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
A) Visual Basic
B) NetBeans
C) Xcode
D) Android Studio
13. What is the difference between print() and println() methods in Java?
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
B) A user-defined function
D) A type of operator
A) First-In-First-Out (FIFO)
B) Last-In-First-Out (LIFO)
A) Favorite color
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
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) +
B) It is platform independent.
27. What is the first step in the Software Development Process as listed in the
summary?
A) Implementation
B) Design
C) Analysis
D) Testing
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
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
A) ==
B) %
C) !=
D) &&
A) Queue
B) Linked List
C) Stack
D) Array
38. Which type of array stores elements in a sequence of items of the same
data type?
A) Two-Dimensional Array
B) Dynamic Array
D) Jagged Array
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
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
A) Arithmetic operators
B) Relational operators
C) Logical operators
D) Assignment operators
A) If/else statements
B) Switch statements
C) GoTo statements
D) Looping
48. What is the final stage of the Software Development Process listed in the
summary?
A) Analysis
B) Design
C) Implementation
D) Testing
B) char
C) System
D) if
A) It is less secure.
54. Which Java command is used to interpret Java bytecodes from the
command prompt?
A) javac
B) java
C) run
D) compile
58. What is the approximate range for a long data type in Java?
A) -+128
B) -32768
C) -2 million
D) -10^18
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()