Java Programming - Arrays Questions And Answers
1. Which of these function is used to allocate memory to array variable in Java?
Loading...
2. Which of these is necessary to specify at time of array initialization?
Loading...
3. What will be printed using following code block?
int[] a = {0,1,2,3,4,5,6,7};
System.out.println(a.length);
Loading...
4. What will happen when following Java code block is compiled and run?
public class A {
public static void main(String argv[]){
int ary[]=new int[]{1,2,3};
System.out.println(ary[1]);
}
}
Loading...
5.
What will happen if following code block is compiled/run?
int[] iArray = new int[10];
iArray.length = 15;
System.out.println(iArray.length);
Loading...
6. 6.Will the following program compile successfully ?
class MyArray
{
public static void main(String[] args)
{
int arr1[]=new int[2]{1,2};
int arr2[]=new int[]{1,2,3};
}
}
Loading...
7.
Given a one dimensional array arr, what is the correct way of getting the number of elements in arr.
Select the one correct answer.
Loading...
8. 8.What is the output of the following program?
class MyMethod
{
static int func( int i)
{
return ++i;
}
public static void main(String[] args)
{
int i=0;
int j=func(i++) + i + func(++i);
System.out.println(i);
System.out.println(j);
}
}
Loading...
9. What is the output of this program?
class evaluate {
public static void main(String args[])
{
int arr[] = new int[] {0 , 1, 2, 3, 4, 5, 6, 7, 8, 9};
int n = 6;
n = arr[arr[n] / 2];
System.out.println(arr[n] / 2);
}
}
Loading...
10. What is the output of this program?
class array_output {
public static void main(String args[])
{
char array_variable [] = new char[10];
for (int i = 0; i < 10; ++i) {
array_variable[i] = 'i';
System.out.print(array_variable[i] + "");
}
}
}
Loading...
Are these questions helpful for you?
Related Quizzes
- Introduction To Java
- Java Network Programming
- Java File Input Output
- Java Socket Programming
- Java Data Types
- Java Operators
- Java Strings
- Java Arrays
- Java Package And Interface
- java.lang Package
- Java Swings
- Java Applets
- Java Exception Handling
- JSP And Servlet
- Struts And Hibernate
- Java Session
- JDBC
- Java Classes And Methods
- Java Generics
- Java Multithreading
Comments: (Your feedback is valuable to us)
how will 5 years ago Reply
how will you convert benzene into glyoxal?