MCQ Single Best Answer Moderate

QGive the output of the following string functions:

 

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

ID: #23885 ICSE Computer Application - Class X - Selection Examination - 2024-25 - MCQ - CALCUTTA PUBLIC SCHOOL 90 views
Question Info
#23885Q ID
ModerateDifficulty
ICSE Computer Application - Class X - Selection Examination - 2024-25 - MCQ - CALCUTTA PUBLIC SCHOOLTopic

Choose the Best Option

Click any option to instantly check if you're correct.

  • A 1. LONGUOGE 2. -32
  • B L0NGU0GE 2. -32
  • C 1. Languoge 2. 32
  • D 1. LANGUOGE 2. 30
Correct Answer: Option 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

Challenge a friend or share with your study group.