OOPS
August 25, 2024OOPS
August 25, 2024OOPS
Question 114 |
What correction is required for following Java code snippet to compile?
int[]x=new int[10];
for(int P=0;P<=X.length();P++)
X[P]=5;
int[]x=new int[10];
for(int P=0;P<=X.length();P++)
X[P]=5;
X[P]=5 should be X(p)=5 | |
P<=X.length() should be P<x.length() </x.length() | |
X.length() should be X.length | |
P++ should be P+1 |
Question 114 Explanation:
Integer data type we are using X.length and character data type we are using function X.length().
→ array.length : length is a final variable applicable for arrays. With the help of length variable, we can obtain the size of the array.
→ string.length() : length() method is a final variable which is applicable for string objects. length() method returns the number of characters presents in the string.
→ array.length : length is a final variable applicable for arrays. With the help of length variable, we can obtain the size of the array.
→ string.length() : length() method is a final variable which is applicable for string objects. length() method returns the number of characters presents in the string.
Correct Answer: C
Question 114 Explanation:
Integer data type we are using X.length and character data type we are using function X.length().
→ array.length : length is a final variable applicable for arrays. With the help of length variable, we can obtain the size of the array.
→ string.length() : length() method is a final variable which is applicable for string objects. length() method returns the number of characters presents in the string.
→ array.length : length is a final variable applicable for arrays. With the help of length variable, we can obtain the size of the array.
→ string.length() : length() method is a final variable which is applicable for string objects. length() method returns the number of characters presents in the string.
Subscribe
Login
0 Comments