Write the result of each evaluated expression in the provide

Write the result of each evaluated expression in the provided blank. Assume the following declarations and initializations. If you believe the expression will result in a compile time (syntax) error or runtime error (exception) write \"compile time error\" or \"runtime error\" respectively. s.length arr.length arr[2] s.length() s.charAt(3) drr.length t.length() s.toUpperCase() s.indexOf(\"o\") s.indexOf(\"o\", 6) s.substring(1, 2) s.substring(s.indexOf(\"wo\")) s.indexOf(s.substring(2, 5)) s.substring(arr[4]) arr[arr(2]]

Solution

a>   s.length      --->     compilation error: cannot find symbol length (length is property of array, length() is a method of string class)

b> (arr.length)   --->    5

c> (arr[2]); ---->     3

d> s.length(); ---> 11

e> s.charAt(3);    --->   l

f> (drr.length);      ---> 100

g> t.length();    ---> 0

h> s.toUpperCase();    ---> HELLO WORLD

i> s.indexOf(\"o\");     --->   4

j> s.indexOf(\"o\",6)   --->   7      //give index of \"o\" starting from 6th position

k> s.substring(1,2)    --> e             //substring from start index to end index-1

l> s.substring(s.indexOf(\"wo\")) ---> world    //index of \"wo\" is passed as a value to substring function

m> s.indexOf(s.substring(2,5))   ----> 2       // substring of s is passed as a value to the indexOf fucntion

n> s.substring(arr[4]) ---> orld         // value 7 is passed into substring

o> arr[arr[2]] ----->    11               // is simplified as arr[3]

 Write the result of each evaluated expression in the provided blank. Assume the following declarations and initializations. If you believe the expression will

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site