Font size
WorksheetsPra-PSPM SC025(F04)
Total questions: 24
Worksheet time: 24mins
Calculate and display BMI when a user enters weight and height. From the value of BMI, display “Please reduce your weight” if BMI is greater and equal to 25.0. If not, print “You have an ideal weight”. Which of the answer below is the correct way in writing the output in IPO of this problem?
"Please reduce your height" or "Please reduce your weight"
value of BMI, "Please reduce your weight" or "You have an ideal weight"
value of BMI or "Please reduce your weight" or "You have an ideal weight"
value of BMI
Sentinel-controlled repitition is often called as
Definite Repetition
Indefinite Repitition
Definite Sentinel loop
Indefinite Sentinel loop
Which of the following is not the type of method calls
obj.sayHello(name);
obj.sayHi(name);
void showWelcome(){
obj.showWelcome();
What links each instruction in a flowchart?
A line
A double line
An arrow
A double arrow
start
input dog_age *// dog age in human years
dog_years= (a)
print dog years
end
Based on the pseudocode given, which calculation are correct to calculate the dog real age(dog_years)
(1 dog years = 7 human years)
Instructions carried out one after another in order is a
series
collection
sequence
list
What is the importance of array?
To store multiple value of the same type using variable
store multiple value using multiple variable
collect data
Enable you to write a program that manipulate small amounts of data
Advantages of defining methods in a program is /are
dividing a bigger complex task into smaller, easily understood tasks.
useful in hiding the implementation details.
Can be used with most of the data types.
the elements can be accessed randomly by using the index number.
FOR loops are
loops which run for a specific number of times
not part of programming
the same as if statements
loops which run an unknown number of times
Methods that contain the _______ keyword in the data type position do not return any data
boolean
public
static
void
int i = 0;
while (i < 5){
System.out.println(i);
i++;
}
What is the output?
0
1
2
3
4
1
2
3
4
5
0
1
2
3
4
5
5
What is the value of number after the following loops is executed?
num = 4;
for(i=7; i<12 && i>=7; i--){
++num;
}
7
5
6
8
Output of the following Java program?
class Test{
public static void main(String[] args){
int arr1[]={1,2,3};
int arr2[]={1,2,3};
if(arr1==arr2){
System.out.println("Same");
}else{
System.out.println("Not same");
}}
Same
Not same
Not Same
Error
Does a programmer always know how long an array will be when the program is being written?
Yes, the program will not compile without the length being declared.
No, the array object is created when the program is running and the length might change from run to run
Yes, otherwise the program will not run correctly
No, arrays can grow to whatever length is needed
Which of the following is an example of a sequence program?
Production line
Computer game
Spreadsheet
Web browser
What will be the output of the following Java program?
class selection_statements{
public static void main(String[] args);
int var1=5;
int var2=6;
if((var2=1) == var1){
System.out.println(var2);
} else {
System.out.println(++var2);
}}
1
2
3
4
Which group of words denotes repetition in pseudocode?
if, then, else, else-if, when
for, repeat until, while, while not
begin, end, input, output, print, read, write
None of these
Ordering burger
will be in which flowchart symbol?
Start/End
Action/Process
Decision
Storage
What is wrong with the following loop?
for(int i=0; i>5; i++){
System.out.println("The square of " + i + " is: " + (i*i) + "/n");
}
This is an infinite loop because I can never get to be greater than 5.
This loop will never execute the loop body because the counter variable starts at 0 and immediately fails the test of >5.
This statement is missing the incrementation statement.
This loop is perfect.
Which of the followings is Java code that starts from the main() method as a mandatory part of every program.
public void static main(String args [])
public void main static (args[] String)
public static void main(String args[])
public static void main[String[] Args]
What is the output for the following statement:
System.out.println("1"+"1");
11
2
Error Message
1
Determine the number of input(s) that is read based on the following input statement.
Scanner in=new Scanner(System.in);
int item[20];
item[10]=in.nextInt();
1
10
9
19
State the sentinel value.
int sum;
sum=0;
int num= in.nextInt();
while(num!=-1)
{
sum = sum+num;
num=in.nextInt();
}
System.out.println(sum);
(a)
Identify the number of output(s) based on the statement below:
'Display the name of five salespersons in a company that received 3% bonus from their salary. Then the program should print their bonus amount and their gross salary.'
5
7
3
2
