Question

Q10: Which of the following is not an error (either a syntax error or a logic...

Q10: Which of the following is not an error (either a syntax error or a logic error)?

  1. Neglecting to include an action in the body of a while statement that will eventually cause the condition to become false.
  2. Spelling a key word (such as while or if) with a capitalized first letter.
  3. Using a condition for a while statement that is initially false.
  4. An infinite loop.

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

  1. 19
  1. 20
  1. 10
  1. 11

Q12: Which statement is true?

  1. Dividing two integers results in integer division.
  2. With integer division, any fractional part of the calculation is lost.
  3. With integer division, any fractional part of the calculation is truncated.
  4. All of the above.

Q13: In an expression containing values of the types int and double, the ________ values are ________ to ________ values for use in the expression.

  1. int, promoted, double.
  2. int, demoted, double.
  3. double, promoted, int.
  4. double, demoted, int.

Q14: Local variables must be ________.

  1. initialized when they are declared.
  2. initialized before their values are used in an expression.
  3. declared and initialized in two steps.
  4. declared at the top of the metho

Q15: Which statement is true?

  1. A while statement cannot be nested inside another while statement.
  2. An if statement cannot be nested inside another if statement.
  3. A while statement cannot be nested inside an if statement.
  4. None of the above is true.

Q16: Which of the following code segments does not increment val by 3:

  1. val += 3:
  2. val = val+1;
    val = val+1;
    val = val+1;
  3. c = 3;
    val = val + (c == 3 ? 2 : 3);

d.    All of the above increment val by 3.

Q17: What does the expression x %= 10 do?

  1. Adds 10 to the value of x, and stores the result in x.
  2. Divides x by 10 and stores the remainder in x.
  3. Divides x by 10 and stores the integer result in x.
  4. None of the above.

Q18: What is the result value of c at the end of the following code segment?

int c = 8;

c++;

++c;

c %= 5;

  1. 0
  1. 1
  1. 3
  1. None of the

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?

  1. 8
  1. 16
  1. 32
  1. 64

Q22: In Java graphics, coordinate units are measured in ________.

  1. dots.
  1. pixels.
  1. points.
  1. inches.

Q23: Keyword ________ indicates the inheritance relationship.

  1. extends
  2. super
  1. inherits
  2. sub
0 0
Add a comment Improve this question Transcribed image text
Answer #1

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

Add a comment
Know the answer?
Add Answer to:
Q10: Which of the following is not an error (either a syntax error or a logic...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • 1.) Using the following declarations and a member of the Array class, int [ ] bArray...

    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...

    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...

    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...

    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...

    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...

    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...

    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...

    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...

    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...

    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...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT