Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

MCQ Presentation

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 32

MCQ PRESENTATION

UNIT - II
20BCA013 Harsh Kukadiya
1. JAVA identifiers are case sensitive or not?

True False
1. JAVA identifiers are case sensitive or not?

True False
2. Which one is not a keyword in Java?

a) synchronized
b) Assert
c) export
d) volatile
2. Which one is not a keyword in Java?

a) synchronized
b) Assert
c) export
d) volatile
3. Range of short is _______?

a) -128 to 127
b) -215 to 215 -1
c) -217 to 217 -1
d) -125 to 124
3. Range of short is _______?

a) -128 to 127
b) -215 to 215 -1
c) -217 to 217 -1
d) -125 to 124
4) What is the output of the below Java code?
int a = 2 - - 7;
System.out.println(a);

a) 9
b) error
c) 10
d) -5
4) What is the output of the below Java code?
int a = 2 - - 7;
System.out.println(a);

a) 9
b) error
c) 10
d) -5
5) What is the output of the Java code snippet?
int a=5, b=10, c=15;
a -= 3;
b *= 2;
c /= 5;
System.out.println(a +" " + b + " " + c);
A) 2 20 3
B) 2 20 5
C) 2 10 5
D) -2 20 3
5) What is the output of the Java code snippet?
int a=5, b=10, c=15;
a -= 3;
b *= 2;
c /= 5;
System.out.println(a +" " + b + " " + c);
A) 2 20 3
B) 2 20 5
C) 2 10 5
D) -2 20 3
6) Arithmetic operators +, -, /, * and % have
which Associativity?

a) Right to Left
b) Left to Right
c) Right to Right
d) Left to Left
6) Arithmetic operators +, -, /, * and % have
which Associativity?

a) Right to Left
b) Left to Right
c) Right to Right
d) Left to Left
7) What is the output of the Java code snippet?
int a=10, b=5, c=3; int d = a+c/2*b;
System.out.println(d);

a) 30
b) 15
c) 32.5
d) 17.5
7) What is the output of the Java code snippet?
int a=10, b=5, c=3; int d = a+c/2*b;
System.out.println(d);

a) 30
b) 15
c) 32.5
d) 17.5
8) What is the output of the below Java program?

int[] marks = {35,65,95};


System.out.print(marks.length + "," + marks[1]);

a) 2,65
b) 3,95
c) 3,65
d) Compiler error
8) What is the output of the below Java program?

int[] marks = {35,65,95};


System.out.print(marks.length + "," + marks[1]);

a) 2,65
b) 3,95
c) 3,65
d) Compiler error
9) What is the output of Java program?

String[] colors = {"RED";"YELLOW";"WHITE"};


System.out.print(colors[2]);

a) RED
b) YELLOW
c) WHITE
d) Compiler error
9) What is the output of Java program?

String[] colors = {"RED";"YELLOW";"WHITE"};


System.out.print(colors[2]);

a) RED
b) YELLOW
c) WHITE
d) Compiler error Array elements must be separated
with Comma(,)s.
10) What will length() return?

a) Size of array
b) No of character
c) Character of array
10) What will length() return?

a) Size of array
b) No of character
c) Character of array
11) What will be the output of the following Java code?

public class Main{


public static void main(String[] args) {
char ch1= 'A';
char ch2= ch1++;
System.out.println(ch1);
System.out.println(ch2);
}
}
a) B b) A
A B

c) A d) B
A A
11) What will be the output of the following Java code?

public class Main{


public static void main(String[] args) {
char ch1= 'A';
char ch2= ch1++;
System.out.println(ch1);
System.out.println(ch2);
}
}
a) B b) A
A B

c) A d) B
A A
12) Which code line could possibly "call" this
method?
public static int SomeMethod(double[ ] array,
int[ ] number)
{...
}

a) int value = SomeMethod(money, grades);


b) SomeMethod(money, grades);
c) double value = SomeMethod(money, grades);
d) int value = SomeMethod(money);
12) Which code line could possibly "call" this
method?
public static int SomeMethod(double[ ] array,
int[ ] number)
{...
}

a) int value = SomeMethod(money, grades);


b) SomeMethod(money, grades);
c) double value = SomeMethod(money, grades);
d) int value = SomeMethod(money);
13) What is the output of the following code fragment?
double [ ] x = new double [ 4];
x[0] = 8.5;
x[1] = 6.5;
x[2] = 9.5;
x[3] = 12.5;
System.out.println(x[1 + 2]);

a) 6.5 9.5
b) 12.5
c) 16
d) 6.5 9.5
13) What is the output of the following code fragment?
double [ ] x = new double [ 4];
x[0] = 8.5;
x[1] = 6.5;
x[2] = 9.5;
x[3] = 12.5;
System.out.println(x[1 + 2]);

a) 6.5 9.5
b) 12.5
c) 16
d) 6.5 9.5
14) What will be the output?

int [ ] evens = {2, 4, 6, 8, 10};


evens[0] = 44;
evens[4] = evens[2];
System.out.println(evens[0] + " " + evens[4]);

a) 54
b) 2 10
c) 44 6
d) 44 10
14) What will be the output?

int [ ] evens = {2, 4, 6, 8, 10};


evens[0] = 44;
evens[4] = evens[2];
System.out.println(evens[0] + " " + evens[4]);

a) 54
b) 2 10
c) 44 6
d) 44 10
15) Which of these is an incorrect array
declaration?

a) int [] arr = new int[5]


b) int arr[] = new int[5]
c) int arr[]arr = new int[5]
d) int arr[] = int [5] new
15) Which of these is an incorrect array
declaration?

a) int [] arr = new int[5]


b) int arr[] = new int[5]
c) int arr[]arr = new int[5]
d) int arr[] = int [5] new
Thank you!

You might also like