0% found this document useful (0 votes)
3 views

Array Question 2

The document is a class test on arrays with a total of 50 marks divided into three sections: multiple-choice questions, output prediction problems, and programming tasks. It includes questions on array definitions, memory storage, and Java-specific array operations, as well as programming exercises for finding the largest and smallest numbers in an array, sorting, and binary searching. The test is designed to assess understanding of arrays in Java and practical coding skills.

Uploaded by

Dipak Saha
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Array Question 2

The document is a class test on arrays with a total of 50 marks divided into three sections: multiple-choice questions, output prediction problems, and programming tasks. It includes questions on array definitions, memory storage, and Java-specific array operations, as well as programming exercises for finding the largest and smallest numbers in an array, sorting, and binary searching. The test is designed to assess understanding of arrays in Java and practical coding skills.

Uploaded by

Dipak Saha
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Class Test ( Array )

Full Marks : 50 Time : 1.30 Hour

A ) Attend All Questions : [ 1 x 10 = 10 ]

1) Which one of the following is a valid Statement ?


a. char[] c= new char(); b. char[] c= new char[5];
c. char [] c= new char(4); d. char [] c= new char[];
2) When you pass an array to a method , the method receives__________________.
a. A copy of the first element. b. A copy of the array
c. The length of the array d. The reference of the array
3) What is an array ?
a. A collection of elements with different types b. A resizable data structure
c. A collection of elements the same type d. A container for storing key-value pairs
4) Which of the following create an empty two-dimensional array with dimensions 2x2 ?
a. int x[][]=new Int[2,2]; b. int x[][]=new int[2][2];
c. int x[][]=new int[][]; d. int x[][]=new int[2x2];
5) Where is an array stored in memory ?
a. Heap b. stack c. both a and b d. none of these
6) what is the index range for the element of an array in java ?
a. 0 to length-1 b. 1 to length-1 c. 1 to length d. 0 to length
7) Array data access using _________.
a. Operator b. Variable c. Index d. Pointer
8) Which package contains the array class that provides method for working with arrays?
a. Java.array b. Java.util c. Java.lang d. Java.math
9) What is a jagged array?
a. An array that contains only primitive data types
b. An array where the elements are of different types
c. An array of arrays where each sub-array can have a different length
d. An array that can only be accessed using a custom key.
10) Which of the following function find the size of array
a. Variable.sizeOf() b. sizeOf(Variable) c. variale.length() d.variable.length
B) Attend All Questions: [ 2X 5 = 10 ]
1) What is the output of this problem ?
public static void main(String args[]) {
String str[] ={ “Hello “ , “ Dear ”, “Students “};
for( int i=0; i<str.length -1 ; i++)
System.out.print(str[i]); }
2) What is the output of this problem ?
public static void main(String args[]) {
int Mult=0;
int Num[] ={5,6,7,8 };
for( int i=0; i<Num.length; i++) {
Mult*=Num[i]; }
System.out.print(Mult); } }

3) What is the output of this problem ?


public static void main(String args[]) {
int Num[] ={5,6,7,8 };
Num[0]=2;
Num[3]=Num[2];
int sum=Num[1]+Num[2];
System.out.print(sum); }

4) What is the output of this problem ?


public static void main(String args[]) {
int Num[] ={5,6,7,8 ,1,5,4};
for( int i=0; i<Num.length; i++) {
System.out.print(Num[i+1]);
} }
5) What is the output of this problem ?
public static void main(String args[]){
boolean val[]=new boolean[10];
for(int i=0;i<5;i++){
if(val[i])
System.out.println(i); }
System.out.println(val[6]); }

C) Attend All Questions [ 10 x 3 = 30 ]


1) Write a program to input integer elements into an array of size 20 and perform the
following operations:
1. Display largest number from the array
2. Display smallest number from the array
3. Display sum of all the elements of the array
2) Write a program to input and sort the Age of ten people. Sort and display them in
ascending order using the selection sort technique.
3) Write a program to perform binary search on a list of integers given below, to search for
an element input by the user. If it is found display the element along with its position,
otherwise display the message "Search element not found".
List of integers: [15, 28, 36, 47, 52, 61, 74, 82, 96, 103]

You might also like