MCQ Practice Single Best Answer Topic: ICSE Computer Application - Class X - Selection Examination - 2024-25 - MCQ - CALCUTTA PUBLIC SCHOOL

Q Give the output of the following string functions:

 

"LANGUAGE".replace('A', '0'); "PROGRAM".compareTo("Program");

Question ID
#23885
Subchapter
ICSE Computer Application - Class X - Selection Examination - 2024-25 - MCQ - CALCUTTA PUBLIC SCHOOL
Action
Choose one option below

Choose Your Answer

Click an option to check whether your answer is correct.

  • A 1. LONGUOGE 2. -32
  • B L0NGU0GE 2. -32
  • C 1. Languoge 2. 32
  • D 1. LANGUOGE 2. 30
Correct Answer: B

Explanation

Explanation:

"LANGUAGE".replace('A', '0');

Replaces all occurrences of 'A' with '0' in the string.

Result: "L0NGU0GE".

"PROGRAM".compareTo("Program");

Compares the strings lexicographically.

Java uses ASCII values, and the difference in case ('P' in uppercase vs. 'p' in lowercase) gives -32.

Share This Question

Share this MCQ with your friends or study group.