Computer Science, asked by suryatripathi15, 5 months ago

Read the following code segment and answer the question number 61-75. String sl = "Lucknow Public School

String s2 - "Lucknow"; String s3 = "College":

String s4 - "Luck";

Q.61- Output of $1.length()

is :

a. 19 e. 21 b. 23 Q.62- Output of s2.charAt(3) is:

d. None of these

b, k d. None of these

a. C

c. I Q.63- Output of s1.indexOf(u) is: a. 1 b. 2

c. 3 Q.64- Output of s2.indexOf('p') is:

d. None of these

a. Error c. 3 b. -1 d. None of these Q.65- Output of s1.substring(0,7).equals(2)

is a. false c. 0

b. true d. None of these Q.66- Output of s1.replace("School", s3) is a. Lucknow Public School

b. College c. Lucknow Public College d. None of these

0.67. Output of s2.substring(4)

Luck c. Luc b. now d. None of these Q.68- Output of s3.lastindexOf(T):

a. 3

c. 0 Q.69. Output of

b. 2 d. None of these

s3.compareTo(sl.substring(04)) a. false b. 1

c. 0 d. None of these 0.70- Output of sl.compareTo(s2) is a 1 b. -1

c 14 d. None of these Q.71- Output of s2.endsWith("now") is a true b. false

e. 1 d. None of these 0.72. Output of s1.charAt(21) is :

a. I e. -1 b. error d. None of these 0.73- Output of Math.sqrt($4.indexOf(u

is:

a. 1.414 c. 1 b. 1.0 d. None of these Q.74- Output of s3.lastindexOf(1)%2 i :

a 0

Page 4 of 51

b. 2

d. None of these​

Answers

Answered by ItzMiracle
98

\huge\boxed{\underline{\sf{\red{ᴀ}\green{ɴ}\pink{s}\orange{ᴡ}\blue{ᴇ}\pink{ʀ}}}}

Answered by dreamrob
0

Given :

String s1 = "Lucknow Public School";

String s2 = "Lucknow";

String s3 = "College";

String s4 = "Luck";

Q.61 - Output of s1.length()

s1 = "Lucknow Public School"

Output : 21

Q.62- Output of s2.charAt(3)

s2 = "Lucknow"

L u c k n o w

0 1 2 3 4 5 6

Output : k

Q.63 - Output of s1.indexOf('u')

s1 = "Lucknow Public School"

L u c k n o w      P u b   l   i   c         S   c  h   o  o   l

0 1 2 3 4 5 6  7  8 9 10 11 12 13  14  15 16 17 18 19 20

Output : 1

Q.64 - Output of s2.indexOf('p')

s2 = "Lucknow"

L u c k n o w

0 1 2 3 4 5 6

Since, 'p' is not present. So, answer is -1

Output : -1

Q.65 - Output of s1.substring(0,7).equals(s2)

s1.substring(0,7) = "Lucknow"

s2 = "Lucknow"

s1.substring(0,7) = s2     (true)

Output = true

Q.66 - Output of s1.replace("School", s3)

s1 = "Lucknow Public School"

s3 = "College"

"School" is replaced by "College"

Output : Lucknow Public College

Q.67 - Output of s2.substring(4)

s2 = "Lucknow"

L u c k n o w

0 1 2 3 4 5 6

Output will be letter at 4 till end of the string

Output : now

Q.68 - Output of s3.lastIndexOf('T')

s3 = "College"

C o l l e g e

0 1 2 3 4 5 6

Since, 'T' is not present. So, output is -1

Output : -1

Q.69 - s3.compareTo(s1.substring(0,4))

s1 = "Lucknow Public School"

L u c k n o w      P u b   l   i   c         S   c  h   o  o   l

0 1 2 3 4 5 6  7  8 9 10 11 12 13  14  15 16 17 18 19 20

s3 = "College"

C o l l e g e

0 1 2 3 4 5 6

s1.substring(0,4) = "Luck"

ASCII of C = 67

ASCII of L = 76

67 - 76 = -9

Output : -9

Q.70 - Output of s1.compareTo(s2)

s1 = "Lucknow Public School"

L u c k n o w      P u b   l   i   c         S   c  h   o  o   l

0 1 2 3 4 5 6  7  8 9 10 11 12 13  14  15 16 17 18 19 20

s2 = "Lucknow"

L u c k n o w

0 1 2 3 4 5 6

Output : 14

Q.71 - Output of s2.endsWith("now")

s2 = "Lucknow"

Output : true

Q.72 - Output of s1.charAt(21)

s1 = "Lucknow Public School"

L u c k n o w      P u b   l   i   c         S   c  h   o  o   l

0 1 2 3 4 5 6  7  8 9 10 11 12 13  14  15 16 17 18 19 20

Output : StringIndexOutOfBoundsException

Q.73 - Math.sqrt(s4.indexOf('u'))

s4 = "Luck"

L u c k

0 1 2 3

'u' is at index 1

Square root of 1 = 1

Output : 1.0

Q.74 - Output of s3.lastIndexOf('l')%2

s3 = "College"

C o l l e g e

0 1 2 3 4 5 6

s3.lastIndexOf('l') : 3

3 % 2 = 1

Output : 1

Similar questions