Q10: Which of the following is not an error (either a syntax error or a logic error)?
Q11: How many times is the body of the loop below executed?
int counter;
counter = 1;
while ( counter < 20 )
{
// body of loop
counter = counter + 2;
} // end while
|
|
|
|
Q12: Which statement is true?
Q13: In an expression containing values of the types int and double, the ________ values are ________ to ________ values for use in the expression.
Q14: Local variables must be ________.
Q15: Which statement is true?
Q16: Which of the following code segments does not increment val by 3:
d. All of the above increment val by 3.
Q17: What does the expression x %= 10 do?
Q18: What is the result value of c at the end of the following code segment?
int c = 8;
c++;
++c;
c %= 5;
|
|
|
|
Q19: Which of the following is not a primitive type?
a. char b. float
c. String d. int
Q20: Which primitive type can hold the largest value?
a. int b. long
c. float d. double
Q21: What is the size in bits of an int?
|
|
|
|
Q22: In Java graphics, coordinate units are measured in ________.
|
|
|
|
Q23: Keyword ________ indicates the inheritance relationship.
|
|
Q10 : Infinite Loop is niether an syntax error or a logic error; In certain condition, we might need to run a program for infinite time, even though in most of the cases we’ll avoid creating infinite loops but there could be some cases where we need to create one. In such scenarios, the loop will terminate when the application exits.
Q 11
it will run for counter = 1,3,5,7,9,11,13,15,17,19
So it will run the loop 10 times
Q12
Dividing two integers results in integer division, e.g. 7/3 = 2
Q13
int promoted to double
lower type are promoted to higher type, here double is higher type
than integer
Q14
initialized before thier values are used in an expression
Q15
None of the above is true
Q16
c=3;
val=val+(c==3?2:3);
for this vase val will be incremented by 2
Q17
Divides x by 10 and stores the remainder in x.
Q18
0
c will have a value of 10, so 10%5 =0
Q19
String
Q20
double
Q21
4byte*8 = 32 bits
Q22
pixels
Q23
extends
Q10: Which of the following is not an error (either a syntax error or a logic...
1.) Using the following declarations and a member of the Array class, int [ ] bArray = new int [10]; int location; Using a method in the Array class, write a statement that would order the values in the bArray array in ascending order. ___________________ HINT: You must write the full statement which includes a call to a method in the Array class. 2.) Using the following declarations and a member of the Array class, int [ ] bArray =...
Question 1 while loops can be used to implement counter-controlled repetition and while loops can be used to implement sentinel-controlled repetition. T/F Question 2 Java does not require that local variables are initialized when declared, but does require that they are initialized prior to use in an expression. T/F Question 3 Select only those options corresponding to Java's primitive types from the list below wide short float bit boolean byte String char double int long word points Question 4 ....
Form B 29. Which of the following statements about the continue statement is true a. The continue statement is used to exit a repetition structure early and continue the execution of the statements following the loop. b. The continue statement is used to continue after a switch statement c. The continue statement does not alter the flow of control d. A continue statement proceeds with the next iteration of the immediately enclosing loop. e. None of the above 30. Inside...
QUESTION 1 Which statement results in the value false? The value of count is 0; limit is 10. (count != 0)&&(limit < 20) (count == 0)&&(limit < 20) (count != 0)||(limit < 20) (count == 0)&&(limit < 20) 10 points QUESTION 2 If this code fragment were executed in an otherwise correct and complete program, what would the output be? int a = 3, b = 2, c = 5 if (a > b) a = 4; if (...
review for the final
1. (1 point) Mark True or False in the left side of problems. (1) We can declare an array of string as string) greetings = {"good", "excellent"); (2) To declare and initialize an int variable i to be 2, we can write int=2; (3) For a properly declared and initialized int variable num, a condition to represent that num is between 10, 100) is written as (num >= 0 || num < 100). (4) Every nested...
1- Correct the syntax errors in the following program, and rewrite the program so that it follows the proper style conventions. What does the program do? (Write it out as a comment). (10 pts) #include <stdio.h> int main() {/* * Calculate and display the difference of two values *) int X, /* first input value */ x, /* second input value */ sum; /* sum of inputs */ X=9, x=7.5 X + x = sum; printf("%d + %d = %d\n";...
Placing Exception Handlers File ParseInts.java contains a program that does the following: Prompts for and reads in a line of input Uses a second Scanner to take the input line one token at a time and parses an integer from each token as it is extracted. Sums the integers. Prints the sum. Save ParseInts to your directory and compile and run it. If you give it the input 10 20 30 40 it should print The sum of the integers...
Been working on this program for hours and keep getting error. PLEASE help and show a working output, Thank you Step 2: Declaring variables Examining the problem we need to have 2 variable to store integer input given by the user. int x,y; Step 3: setting up Scanner object and scanning the inputs import java.util.Scanner; Create Scanner class object by using following syntax Scanner=new Scanner(System.in); /* give some name to the object which ever you want */ Ask the...
Multiple Choice Identify the choice that best completes the statement or answers the que 1. Which of the following is a valid Java identifier? Spay b. 4myGrade! c. newGrade! d. 1dollar static final int EndVal-1: int double; int num console.nextInt(); while (num != Endval) double num * 2; System.out.println (double); num console.next1nt(); 2. The above code is an example of a(n)--while loop. a. flag-controlled b. counter-controlled c. EOF-controlled d. sentinel-controlled 3. The length of the string "first java program" is:...
15. Which one of the following two conditional statements is correct in determining if m falls outside a range of values, (m <= 0) or (m > n)? Circle one answer: (a) if(m <0||m >n) (b) if(m <= 0 && m >n) (c) if(0 <= m || m <n) (b) if (0 <= m && m <n) 16. The statement (or command or function) is used inside a loop to send control of the program to the last line of...