JF S1-S5 MT (Questions and Answers) Highlighted

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 23

5/24/22, 1:07 AM JF S1-S5 MT

NAME :
CLASS :
JF S1-S5 MT
135 Questions DATE :

1. An object may interact with another object by invoking methods.

A True B False

2. Which of the following language is called a procedural language?

A C++ B Java

C C D Java C

3. You design a Circle class with various fields and methods. Which of the following could be
fields in this class? Distinguish which of these are between the properties and behavior.

A calculateDiameter() B color

C calculateArea() D radius

E calculateCircumference()

4. In object oriented programming, an object comprises of properties and behaviors where


properties represented as fields of the object and behavior is represented as method.

A True B False

5. In object oriented programming, there is an emphasis on which of the following two:

A Writing algorithms. B Creation of procedures.

Modeling objects. Object interaction without a prescribed


C D
order.

6. You can set any number of breakpoints for your program.

A True B False

https://quizizz.com/print/quiz/5c6d8cc2de1fe5001a9d60ec 1/23
5/24/22, 1:07 AM JF S1-S5 MT

7. When the program runs normally (when not in debug mode), which statement is true about
breakpoints?

Breakpoints will not have any effect on Breakpoints will stop program execution
A program execution. B at the first breakpoint.

Breakpoints will stop program execution Any Breakpoint will stop program
C at the last breakpoint. D execution.

8. Which of the following three statements are true about breakpoint?

A They help with debugging. B They pause code execution.

They insert break statements. They can be used to check the current
C D
state of the program

E They abruptly ends the code execution.

9. Which of the following are considered Whitespace?


(Choose all correct answers)

A Space in the print statements. B Space between the [ ] braces.

C Indentation before the code. D Blank lines in the code.

E Space between words.

10. Which of the following two features are supported by the NetBeans IDE.

NetBeans highlights matching braces. NetBeans automatically runs the program


A B once all the braces in the code are
matched.

Once NetBeans spots a problem, it won’t NetBeans provides a shortcut to format


C allow you to continue coding until the D whitespace.
problem is fixed.

11. Which of the following 2 statements are true about whitespace?

Whitespace increases execution time of Whitespace eliminates typing mistakes


A B
your program. while programming.

Whitespace reduces the performance of Whitespace makes your code more


C D
the program. readable

Whitespace helps to keep your code


E
organized.

https://quizizz.com/print/quiz/5c6d8cc2de1fe5001a9d60ec 2/23
5/24/22, 1:07 AM JF S1-S5 MT

12. A software feature may allow the user to perform a specific task.

A True B False

13. If the requirement step of the Spiral Model of development is forgotten, which of the
following could occur?

A Code becomes messy. B Solutions seem elusive.

The Program gives inaccurate results. Required software features are missing
C D
from the program.

14. The Spiral Model reflects an iterative development process.

A True B False

15. You’d like to see a movie with a few friends. You write an email to confirm plans.

Hi Friends,
There’s a new movie “Attack of the Duke!” premiering this Friday at Oracle Cinema at 4:30
PM. The cinema is at the corner of South Street and Walnut Ave. Subway would be the best
way to get there.

Would any of you be interested in going?

Which of the following are requirements for this plan?

Watch “Attack of the Duke!” on Friday at Reach the cinema by 4:00 PM.
A B
Oracle Cinema at 4:30 PM.

Travel via subway. Double check the location by verifying


C D
you’re on South Street and Walnut Ave.

16. What is the correct order of steps in the Spiral Model of Development?

A Design, Requirements, Develop, Test B Requirements, Design, Test, Develop

C Design, Develop , Requirements, Test D Requirements, Design, Develop, Test

17. During the Design phase of software development, the programmer implements features
gathered during the Requirement phase.

A True B False

https://quizizz.com/print/quiz/5c6d8cc2de1fe5001a9d60ec 3/23
5/24/22, 1:07 AM JF S1-S5 MT

18. You have a beautiful garden at home. On Sunday, you start budding your rose plant to
make few more samples of rose plants to plant in the garden.

Can you categorize how this scenario could be represented by classes and instances?

Samples of the rose plant are called Samples are the class and the rose plant is
A B
classes and not the actual rose plant. the instances of samples.

Rose plant is the object and samples are Rose plant is the class and the samples
C not instances of the plant because they D generated from the rose plant are
have not grown yet. instances of that class.

19. There are several fields and methods in a Shirt class. Which of the following could be a
method in the Shirt class?

A size B getShirtSize()

C color D price

20. Java mostly reads code line-by-line.

A True B False

21. Which two are the correct syntax for adding comments?

Start with a slash- star (/*). End with slash- Start with two slashes and a star (//*). End
A B
star (/*). with a star-slash (*/).

Start with a slash-star (/*). End with a star- Start with two slashes (//). End with two
C D
slash (*/). slashes (//).

Start with two slashes (//). End when the


E
line ends.

22. A Java program can be written in the single line.

A True B False

23. What is the purpose of adding comments in the code?

Provide an explanation about the code to To provide better security to the program.
A B
the programmer.

It increases the execution time of the Provide good look and feel of the code.
C D
code.

24. Code within curly braces is called a “Block of code”.

A True B False

https://quizizz.com/print/quiz/5c6d8cc2de1fe5001a9d60ec 4/23
5/24/22, 1:07 AM JF S1-S5 MT

25. Java is a strongly typed language; therefore you must declare a data type for all variables.

A True B False

26. Which is valid syntax to declare and initialize a String variable?

A String x= “Java”; B String x = Java;

C String “x” = Java; D String “x” = “Java”;

27. Which two data types are appropriate for their variable?

A double checkingAmount = 1500; B boolean age = 20;

C int averageDollarAmount = 19.95; D String firstName = “Alex”;

28. Which two statements will not compile?

A double double=10; B int age=20;

C int break=10; D double salary = 20000.34;

E int abc = 10;

29. Which two are valid?

A double doubleVar1; doubleVar2 = 3.1. B double doubleVar1, doubleVar2 = 3.1;

double doubleVar1 = 3.1; double double doubleVar1, double doubleVar2 =


C D
doubleVar2 = 3.1; 3.1;

30. Assigning a value to the variable is called “initialization”.

A True B False

31. Identify the variable declared in the given code.

A a B Welcome

C 2 D int

32. How many bits are in a byte?

A 2 B 4

C 6 D 7

E 8

https://quizizz.com/print/quiz/5c6d8cc2de1fe5001a9d60ec 5/23
5/24/22, 1:07 AM JF S1-S5 MT

33. Which two are mathematical operators?

A + B -

C # D @

34. Which keyword makes a variable’s value unchangeable?

A const B final

C static D break

35. Which two are recommended practices for naming final variables?

A Capitalize every letter B Separate words with an underscore

C Capitalize first letter D Separate words with an space

36. This declaration represents a long data type.


long a = 123L;

A True B False

37. What value is assigned to x?

int x = 25 - 5 * 4 / 2 - 10 + 4;

A 8 B 9

C 34 D 7

38. Which of the following data types is the largest?

A byte B short

C int D long

39. What is the output?

Value of age: 20 Value of age: 20


A Value of age: 8 B Value of age: 28
Value of age: 10 Value of age: 38

Value of age: 20 Value of age: 20


C Value of age: 208 D Value of age: 8
Value of age: 20810 Value of age: 9

https://quizizz.com/print/quiz/5c6d8cc2de1fe5001a9d60ec 6/23
5/24/22, 1:07 AM JF S1-S5 MT

40. Which of the following two statements are true about variables?

Variables will be ignored by compiler. The value assigned to a variable may


A B never change.

They allow code to be edited more They make code becomes flexible.
C efficiently. D

41. Which two are valid assignments of a?

A int a = 10 B int a; a = 10;

C int a = “10”; D int a = 10;

42. Identify the names of two variables used in the given code.

A strVal B Hello

C int D String

E intVal

43. What is the output?

A World B Hello

Hello World Hello


C D
World

44. Which data type is most commonly used to represent numeric data?

A int B float

C String D short

45. Assuming x is an int, which of the following are ways to increment the value of x by 1?

(Choose all correct answers)

A x = x +1; B x = +1;

C x+; D x++;

E x += 1;

https://quizizz.com/print/quiz/5c6d8cc2de1fe5001a9d60ec 7/23
5/24/22, 1:07 AM JF S1-S5 MT

46.

Value of x is 0 Value of x is 100


A B
Value of y is 1 Value of y is 1

Value of x is 100 Value of x is 100


C D
Value of y is 1 Value of y is 101

47. What is the correct way to cast a long to an int?

A int longToInt = int 20L; B int longToInt = (int)20L;

C int longToInt = 20L(int); D int longToInt = 20L;

48. Which two statements are true about type casting?

Type casting retains the size of the value Type casting cannot be performed on
A B
or the original data type. equations.

Type casting lowers the range of possible Type casting changes the type of the value
C D
values. stored.

49. Which is a valid way to parse a String as an int?

A int intVar1 = (int)"100"; B int intVar1 = "100";

int intVar1 = Integer.parseInt("100"); int intVar1 = Integer.parseInt("One


C D
Hundred");

50. A double with the value of 20.5 is cast to an int. What is the value of the int?

A 21 B 25

C 20 D 20.5

51. A short data type can be promoted to which of the following types?
(Choose all correct answers)

A boolean B byte

C long D double

E int

https://quizizz.com/print/quiz/5c6d8cc2de1fe5001a9d60ec 8/23
5/24/22, 1:07 AM JF S1-S5 MT

52. When the result of an expression is assigned to a temporary memory location, what is the
size of memory allocated?

The size of the smallest data type used in A default size is allocated.
A B
the expression.

The size of the any data type used in the The size of the largest data type used in
C D
expression. the expression.

53. Double quotes may be used with char literal values.

A True B False

54. An Object cannot have String objects as properties.

A True B False

55. What is the output?

A Hello World B “Hello” “World” “2016” “!”

C “Hello World 2016” D Hello World 2016 !

56. The print() method prints to the console and automatically creates a line.

A True B False

57. Which two statements are true about String concatenation.

String concatenation cannot be done with Strings can be combined using the ‘+’
A numbers. B operator

String concatenation can be done with String concatenation cannot be done with
C String variables and String Literals. D more than two String Literals.

58. These two code fragments perform the same task.

A True B False

59. System.in readies Scanner to collect input from the console.

A True B False

https://quizizz.com/print/quiz/5c6d8cc2de1fe5001a9d60ec 9/23
5/24/22, 1:07 AM JF S1-S5 MT

60. It's best-practice to close the Scanner stream when finished

A True B False

61. A String can be created by combining multiple String Literals.

A True B False

62. The Java compiler automatically promotes byte, short, and chars data type values to int data
type.

A True B False

63. What is parsing?

Converting numeric data to a specified Converting numeric data to text


A B
numeric data type

C Converting text to numeric data D Reading text from numeric data

64. Automatic promotion from smaller data type to a larger data type is not allowed in Java.

A True B False

65. Given the expression:

String message = ”Hello World”;

Which is the String Literal?

A String message = ”Hello World”; B message

C String message D Hello World

66. Which is the correct declaration for a char data type?

A char size = ’M’; B char size = ’Medium’;

C char size = “Medium”; D char size = “M”;

67. char is the primitive textual data type in Java.

A True B False

68. In Java, char is a primitive data type, while String is an object data type.

A True B False

https://quizizz.com/print/quiz/5c6d8cc2de1fe5001a9d60ec 10/23
5/24/22, 1:07 AM JF S1-S5 MT

69. Which two statements are true about the Scanner class?

A Scanner object doesn’t have fields and A Scanner object opens a stream for
A B
methods. collecting input.

C A Scanner’s delimiter can be changed. D Scanners cannot read text files.

70. You write a statement that assigns a value to a String variable as shown below.

String input = ”This is Java Program”;

This way of assigning values to variables is known as hard-coding.

A True B False

71. Given the import statement:


import java.awt.font.TextLayout;
which is the package name?

java.awt.font java.awt
A B

java awt.font
C D

72. The classes of the Java class library are organized into packages.

A True B False

73. The JFrame and JOptionPane classes are in the javax.swing package. Which two will import
those classes?

A import javax.swing.*; B import javax.swing.J*;

import javax.swing.JOptionPane; import javax.swing;


C D
import javax.swing.JFrame;

74. Which statement is true about packages?

A package makes it difficult to locate the A package contains a group of related


A B
related classes. classes.

Packages of the Java class library do not A package doesn’t contain a group of
C D
contain related classes. related classes.

https://quizizz.com/print/quiz/5c6d8cc2de1fe5001a9d60ec 11/23
5/24/22, 1:07 AM JF S1-S5 MT

75. Which of the following wild card character is used to import all the classes in a particular
package?

A ; B !

C ~ D *

76. Import statements are placed above the class definition.

A True B False

77. Which package is implicitly imported?

A java.lang B java.math

C java.awt D java.io

78. Which of the following are the arguments in the following method?

Employee emp = new Employee();


emp.calculateSalary(100000, 3.2, 15);

A emp.calculateSalary(100000, 3.2, 15); B calculateSalary(100000, 3.2, 15);

C emp D 100000, 3.2, 15

79. How many arguments does the following method accept?

A 1 B 3

C 2 D 0

80. Object instantiation is done using what keyword?

A void B instance

C System D new

81. Which of the following statements are true?


(Choose all correct answers)

Methods cannot be written with Parameter values can never be used


A B
parameters. within the method code block.

Methods can be written with any number Methods can never be written with more
C D
of parameters. than four parameters.

Parameter values can be used within the


E
method code block.

https://quizizz.com/print/quiz/5c6d8cc2de1fe5001a9d60ec 12/23
5/24/22, 1:07 AM JF S1-S5 MT

82. void type methods don’t return any values

A True B False

83. You’re designing banking software and need to store 10000 customer accounts with
information on the accountholder’s name, balance, and interest rate. The best approach is
store 30000 separate variables in the main method.

A True B False

84. In Java, methods usually hold the properties of an object.

A True B False

85. Which of the following scenarios would be ideal for writing a method?

When you don’t find similar lines of code For every five to six lines of code.
A B
to describe an object’s behavior.

When you don’t want to repeat similar To group similar data types together
C lines of code to describe an object’s D
behavior.

86. Which two are valid import statements of the Scanner class?

A import java.util.*; B import java.util.Scanner;

C import java.util; D import java.*;

87. The import statement consists of two parts.

import package.className;

One is the package name and the other is the classname.

A True B False

https://quizizz.com/print/quiz/5c6d8cc2de1fe5001a9d60ec 13/23
5/24/22, 1:07 AM JF S1-S5 MT

88. Which is a valid way of calling the testMethod in the TestClass? Assume a testInstance has
been created.

public void testMethod(int x, double y){


System.out.println(x/y);
}

A testInstance.testMethod(10); B testInstance.testMethod(10, 3.5);

C testInstance.testMethod(10, 3.5, 0); D testInstance.testMethod(3.5, 10);

E testInstance.testMethod(3.5);

89. Once an object is instantiated, how might its fields and methods be accessed in Java?

A Using the double-colon(::) operator B Using the dot(.) operator

C Using the comma(,) operator D Using the colon(:) operator

90. An argument is a value that's passed during a method call

A True B False

91. Methods allow all instance of a class to share same behaviors.

A True B False

92. You need to generate random integer values between 0 and 80 (inclusive). Which statement
should you use?

A nextInt(0-79); B nextInt(80);

C nextInt(); D nextInt(81);

93. Which values are returned by the method nextBoolean();

A Returns the next value. B Either a true or false.

C Nothing is returned. D An integer value.

94. Using the Random class requires an import statement.

A True B False

https://quizizz.com/print/quiz/5c6d8cc2de1fe5001a9d60ec 14/23
5/24/22, 1:07 AM JF S1-S5 MT

95. Which class is used to generate random numbers?

A Number B Integer

C Double D Random

96. Which two are the features of the Math class?

The Math methods can be invoked Common math functions like square root
A without creating an instance of a Math B are taken care of in the language.
object.

You don’t have to worry about the data Math methods can be invoked with Strings
C D
type returned from a Math method. as arguments.

97. What is the package name which contains Math class?

A java.awt B java.lang

C java.net D java.io

98. What is the approximate value of PI?

A 2.718 B The value varies.

C 3.141 D 0

99. Which is NOT true?

Static methods must be of return void. Static methods can be invoked through an
A B
instance of a class

Static methods can be invoked through A class can have multiple static methods.
C D
the class name.

100. What is the output?

A JAva World! B Java World!

C JavA World! D JAvA World!

101. String objects are immutable.

A True B False

https://quizizz.com/print/quiz/5c6d8cc2de1fe5001a9d60ec 15/23
5/24/22, 1:07 AM JF S1-S5 MT

102. What is the output?

A orld! B rld!

C ld! D rld

103. What is the output?

A Compilation error. B Java World! 8

C Java World! + 8 D Java World!8

104. What is the output of the following code?

A Java World B World

C JavaWorld D Java

105. A String is a sequence characters.

A True B False

106. The String class must be imported using java.lang.String;

A True B False

107. The indexOf() method returns the index value of a character in the string.

A True B False

108. The String concat() method concatenates only String data types.

A True B False

109. The replaceFirst() method replaces only the first occurrence of matching character pattern
in a string.

A True B False

110. Which method returns the length of a String?

A charAt() B findLength ()

C length() D compareTo()

https://quizizz.com/print/quiz/5c6d8cc2de1fe5001a9d60ec 16/23
5/24/22, 1:07 AM JF S1-S5 MT

111. The Math class methods can be called without creating an instance of a Math object.

A True B False

112. You need to generate random integer values in the range 2 through 10. This code fragment
will produce the desired result.

Random r = new Random();


r.nextInt(9) + 2;

A True B False

113. A break statement causes control to transfer to the end of the switch statement.

A True B False

114. Which two of the following data types can be used in a switch statement?

A int B boolean

C float D String

115. What is the output?

A Compilation error B Vowels

C Consonants D Vowels

116. What is the output?

A Congratulations B A

Congratulations! Good Work Average Failed


C D
Barely Passing Failed

117. A String comparison with == compares the Strings’ locations in memory and not the
content of the String.

A True B False

https://quizizz.com/print/quiz/5c6d8cc2de1fe5001a9d60ec 17/23
5/24/22, 1:07 AM JF S1-S5 MT

118. How should Strings be compared?

A == B The equals() method

C = D ~=

119. What is the output?

A JavaProgramming B Java Programming

C False D True

120. What is the output?

A Bob is 43 Bob is 50 B Bob is 50

C Bob is 43 D No output

121. An if/else statement is used when you need to choose between two alternatives.

A True B False

122. Which three are conditional statements?

A for loop B do while loop

C switch statement D if statement

E if/else statement

123. Which are used in a boolean expression?

(Choose all correct answers)

A Variables B Errors

C Operators D Loops

124. In Java, an if statement can be nested inside another if statement.

A True B False

https://quizizz.com/print/quiz/5c6d8cc2de1fe5001a9d60ec 18/23
5/24/22, 1:07 AM JF S1-S5 MT

125. In a boolean expression which uses the && operator, what would make this expression
evaluate to true?

boolean x = (firstCondition && secondCondition);

If both the first condition and second If the first condition is true, but the second
A B
condition are false condition is false

If the first condition is false, but the If both the first condition and second
C D
second condition is true condition are true

126. A customer is eligible for a discount based on certain criteria.


Under what conditions does “You qualify for a discount” print?
(Hint: There may be more than one correct answer)

(Choose all correct answers)

When rewardPoints is more than 2000 or When purchase is 4000 and rewardPoints
A purchase greater than 1000 B is 2000

When purchase is 2000 regardless of the When rewardPoints is more than 1000
C value of rewardPoints D and purchase is 1000

127. What is the result?

A I scored 1 point B I scored 10 points

C Compilation error D I scored 1 point 10 points

128. Which two are not logical operators?

Choose all correct answers)

A + B %

C && D !

E ||

https://quizizz.com/print/quiz/5c6d8cc2de1fe5001a9d60ec 19/23
5/24/22, 1:07 AM JF S1-S5 MT

129. An employee is eligible for a bonus based on certain criteria.


Under what conditions does “Eligible for a bonus” print?

int rating;
int experience;
if (rating > 1 && experience == 5) {
System.out.println (“Eligible for a bonus”);
}

A 5 experience and 1 rating B 5 experience and 2 or more rating

C 5 rating and 1 experience D Less than 5 experience and 1 rating.

130. What are the possible values of a boolean data type in Java?

A good/bad B yes/no

C 0/1 D true/false

131. Which operator is used to test if both sides of a boolean expression are equal?

A <= B ==

C >= D =

132. The equal sign (=) is used to make an assignment, whereas the == sign merely makes a
comparison and returns a boolean.

A True B False

133. The switch statement is a more efficient way to write code when dealing with a large range
of unknown values.

A True B False

https://quizizz.com/print/quiz/5c6d8cc2de1fe5001a9d60ec 20/23
5/24/22, 1:07 AM JF S1-S5 MT

134. What is the output?

public static void main(String args[]) {


char grade ='E';
if (grade == 'A') {
System.out.println("Excellent performer");
}else if (grade == 'B') {
System.out.println("Good Performer");
}else if (grade == 'C') {
System.out.println("Average Performer");
}else {
System.out.println("Below Average Performer");
}
}

A Not a Good Performer B Excellent performer

C Below Average Performer D Below Performer

135. Which two of the following data types can be used in a switch statement?

(Choose all correct answers)

A float B String

C boolean D int

https://quizizz.com/print/quiz/5c6d8cc2de1fe5001a9d60ec 21/23
5/24/22, 1:07 AM JF S1-S5 MT

Answer Key

1. a 2. c 3. b, d 4. a

5. c, d 6. a 7. a 8. b, a, d

9. c, d, e 10. a, d 11. d, e 12. a

13. d 14. a 15. a 16. d

17. b 18. d 19. b 20. a

21. c, e 22. a 23. a 24. a

25. a 26. a 27. d, a 28. a, c

29. c, b 30. a 31. a 32. e

33. a, b 34. b 35. a, b 36. a

37. b 38. d 39. a 40. c, d

41. b, d 42. e, a 43. a 44. a

45. a, d, e 46. d 47. b 48. c, d

49. c 50. c 51. e, d, c 52. d

53. b 54. b 55. d 56. b

57. c, b 58. a 59. a 60. a

61. a 62. a 63. c 64. b

65. d 66. a 67. a 68. a

69. b, c 70. a 71. a 72. a

73. a, c 74. b 75. d 76. a

77. a 78. d 79. b 80. d

81. c, e 82. a 83. b 84. b

85. c 86. a, b 87. a 88. b

89. b 90. a 91. a 92. d

93. b 94. a 95. d 96. b, a

97. b 98. c 99. a 100. d

101. a 102. b 103. d 104. c

105. a 106. b 107. a 108. a


https://quizizz.com/print/quiz/5c6d8cc2de1fe5001a9d60ec 22/23
5/24/22, 1:07 AM JF S1-S5 MT

109. a 110. c 111. a 112. a

113. a 114. a, d 115. c 116. c

117. a 118. b 119. d 120. c

121. a 122. e, c, d 123. a, c 124. a

125. d 126. b, c 127. b 128. b, a

129. b 130. d 131. b 132. a

133. b 134. c 135. d, b

https://quizizz.com/print/quiz/5c6d8cc2de1fe5001a9d60ec 23/23

You might also like