Java Data Types, Variables and Arrays Mcqs
Our collections of Multiple choice questions and answers focuses on study of Java Data Types, Variables and Arrays . These questions are chosen from a collection of most authoritative and best reference books on Java Data Types, Variables and Arrays. Our aim is to prepare an individual for competitive exams like NTS, GAT, ECAT, University and College entrance exams and various tests and job interviews. One should practice our Mcqs to assimilate Data Types, Variables and Arrays comprehensively.
- Home
- »
- Languages
- »
- Programming Languages Mcqs
- »
- Java Programming Mcqs
- »
- Data Types Variables and Arrays...
- »
- Page 3
Java Programming Mcqs
- Data Types Variables and Arrays Mcqs
- Exception Handling in Java Mcqs
- Interfaces and Packages Mcqs
- Java Classes and Methods Mcqs
- Java Event Handling Mcqs
- Java Inheritance Mcqs
- Java IO and Applets Mcqs
- java lang and java io Mcqs
- Java Language Fundamentals Mcqs
- Java Operators and Control Statements Mcqs
- java utilities Mcqs
- Miscellaneous Topics in Java Mcqs
- Multithreading in Java Mcqs
- Serialization and Networking Mcqs
- Session Management and JSP and Servlet Mcqs
- String Handling
Computer MCQS
Sciences MCQS
33.
What will this code print?
int arr[] = new int [5];
System.out.print(arr);
int arr[] = new int [5];
System.out.print(arr);
0
Value stored in arr[0].
00000
Class name@ hashcode in hexadecimal form
Answer & Solution
No Solution for this Answer..! Report or Discus this Question
34.
Which of these is an incorrect Statement?
It is necessary to use new operator to initialize an array
Array can be initialized using comma separated expressions surrounded by curly braces
Array can be initialized when they are declared
None of the mentioned
Answer & Solution
No Solution for this Answer..! Report or Discus this Question
35.
Which of these is necessary to specify at time of array initialization?
Row
Column
Both Row and Column
None of the mentioned
36.
What is the output of this program?
class array_output
{
public static void main(String args[])
{
int array_variable [] = new int[10];
for (int i = 0; i < 10; ++i)
{
array_variable[i] = i;
System.out.print(array_variable[i] + " ");
i++;
}
}
}
class array_output
{
public static void main(String args[])
{
int array_variable [] = new int[10];
for (int i = 0; i < 10; ++i)
{
array_variable[i] = i;
System.out.print(array_variable[i] + " ");
i++;
}
}
}
0 2 4 6 8
1 3 5 7 9
0 1 2 3 4 5 6 7 8 9
1 2 3 4 5 6 7 8 9 10
Answer & Solution
No Solution for this Answer..! Report or Discus this Question
37.
What is the output of this program?
class multidimention_array
{
public static void main(String args[])
{
int arr[][] = new int[3][];
arr[0] = new int[1];
arr[1] = new int[2];
arr[2] = new int[3];
int sum = 0;
for (int i = 0; i < 3; ++i)
for (int j = 0; j < i + 1; ++j)
arr[i][j] = j + 1;
for (int i = 0; i < 3; ++i)
for (int j = 0; j < i + 1; ++j)
sum + = arr[i][j];
System.out.print(sum);
}
}
class multidimention_array
{
public static void main(String args[])
{
int arr[][] = new int[3][];
arr[0] = new int[1];
arr[1] = new int[2];
arr[2] = new int[3];
int sum = 0;
for (int i = 0; i < 3; ++i)
for (int j = 0; j < i + 1; ++j)
arr[i][j] = j + 1;
for (int i = 0; i < 3; ++i)
for (int j = 0; j < i + 1; ++j)
sum + = arr[i][j];
System.out.print(sum);
}
}
11
10
13
14
39.
What will this code print?
int arr[] = new int [5];
System.out.print(arr);
int arr[] = new int [5];
System.out.print(arr);
0
Value stored in arr[0].
00000
Garbage value
Answer & Solution
No Solution for this Answer..! Report or Discus this Question
40.
What is the output of below snippet?
Object[] names = new String[3];
names[0] = new Integer(0);
Object[] names = new String[3];
names[0] = new Integer(0);
ArrayIndexOutOfBoundsException
ArrayStoreException
Compilation Error
Code runs successfully
Answer & Solution
No Solution for this Answer..! Report or Discus this Question
41.
Generics does not work with?
Set
List
Tree
Array
42.
How to sort an array?
Array.sort()
Arrays.sort()
Collection.sort()
System.sort()
Answer & Solution
No Solution for this Answer..! Report or Discus this Question
43.
How to copy contents of array?
System.arrayCopy()
Array.copy()
Arrays.copy()
Collection.copy()
Answer & Solution
No Solution for this Answer..! Report or Discus this Question
44.
Where is array stored in memory?
Heap space
Stack space
Heap space and stack space
First generation memory
Answer & Solution
No Solution for this Answer..! Report or Discus this Question
45.
An array elements are always stored in ________ memory locations?
Sequential
Random
Sequential and Random
Binary search
Answer & Solution
No Solution for this Answer..! Report or Discus this Question
46.
What is the range of short data type in Java?
-128 to 127
-32768 to 32767
-2147483648 to 2147483647
None of the mentioned
Answer & Solution
No Solution for this Answer..! Report or Discus this Question
47.
What is the range of byte data type in Java?
-128 to 127
-32768 to 32767
-2147483648 to 2147483647
None of the mentioned
Answer & Solution
No Solution for this Answer..! Report or Discus this Question