Tag: science & technology

Questions Related to science & technology

Multiple choice general knowledge science & technology
  1. The program has a syntax error

  2. The program has a runtime error

  3. The program runs fine, but displays nothing

  4. The program runs fine and displays It is even!

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

The program prints 'It is even!' because the if condition uses assignment (=) instead of equality comparison (==). The statement 'even = true' assigns true to the variable even and returns true as the expression result, so the if block executes. This is a common mistake - using assignment instead of comparison. There is no syntax or runtime error, and output is produced.

Multiple choice general knowledge science & technology
  1. The program has a syntax error because the required break statement is missing in the switch statement

  2. The program has a syntax error because the required default case is missing in the switch statement

  3. The switch control variable cannot be double

  4. No errors

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

Java's switch statement only works with integral types (int, byte, short, char), String, or enum - not floating-point types like double or float. Using a double as the switch expression is a compilation error.

Multiple choice general knowledge science & technology
  1. 5

  2. 6

  3. 7

  4. 8

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

The loop executes three iterations: item=1 adds 1 to sum (sum=1), item=2 adds 2 (sum=3), item=3 adds 3 (sum=6). When sum becomes 6, it exceeds 4 and the break statement exits the loop before checking the while condition.

Multiple choice general knowledge science & technology
  1. A

  2. AB

  3. AC

  4. ABC

  5. compile-time error

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

Strings in Java are immutable - the concat() method returns a new String but does not modify the original. So str.concat("B") is ignored. The += operator creates a new String "AC" and assigns it back to str.

Multiple choice general knowledge science & technology
  1. The program cannot compile because the compiler cannot determine which max method should be invoked

  2. The program cannot compile because you cannot have the print statement in a non-void method

  3. The program runs and prints "max(int, double) is invoked" followed by 2

  4. The program runs and prints "max(double, int) is invoked" followed by 2

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

When max(1, 2) is called with two int arguments, Java's compiler cannot determine whether to invoke max(int, double) or max(double, int) since both require an implicit type conversion (int to double). This ambiguity causes a compilation error.

Multiple choice general knowledge science & technology
  1. The program runs and prints 2 once

  2. The program runs and prints 2 twice

  3. The program has a syntax error because the second m method is defined, but not invoked in the main method

  4. The program has a syntax error because the two methods m have the same signature

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

Methods are distinguished by their signature - the method name AND parameter list (types and order). Both m() methods have the same signature (m(int)) - only the return type differs, which is not sufficient for overloading. This causes a compilation error.

Multiple choice general knowledge science & technology
  1. True

  2. False

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

Neurons in the brain can indeed live an entire lifetime. Unlike most other cells that undergo regular division and replacement, neurons are primarily formed during development and persist throughout life. This makes them among the longest-living cells in the human body, along with some cardiac muscle cells.

Multiple choice general knowledge science & technology
  1. True

  2. False

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

Apples contain pectin, a soluble fiber that binds to cholesterol in the digestive tract and helps remove it from the body. This mechanism can help lower LDL cholesterol levels. Pectin forms a gel-like substance that traps cholesterol and prevents its absorption, making it beneficial for heart health.