Methods
- What is the output of this program?
public class Result
{
public static void main(String args[])
{
byte array0[] = { 71, 72, 73, 74, 75, 76 };
byte array1[] = { 77, 78, 79, 80, 81, 82 };
System.arraycopy(array0 , 2, array1, 1, array0.length-2);
System.out.print(new String(array0) + " " + new String(array1));
}
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: D
GHIJKL MIJKLR
- What is the output of this program?
public class Result
{
public static void main(String args[])
{
byte array0[] = { 71, 72, 73, 74, 75, 76 };
byte array1[] = { 77, 78, 79, 80, 81, 82 };
System.arraycopy(array0 , 0, array1, 0, array0.length);
System.out.print(new String(array0) + " " + new String(array1));
}
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: B
System.arraycopy() is a method of class System which is used to copy a string into another string.
- What is the output of this program?
public class Result
{
public static void main(String args[])
{
long start, end;
start = System.currentTimeMillis();
for (int k = 0; k < 10000000; k++);
end = System.currentTimeMillis();
System.out.print(end - start);
}
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: E
end time is the time taken by loop to execute it can be any non zero value depending on the System.
- Which of the following is method of System class is used to find how long a program takes to execute?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: B
currentTimeMillis()
- What is the output of this program?
public class Result
{
public static void main(String args[])
{
Long n = new Long(230);
System.out.print(n.hashCode());
}
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: C
230