You are on page 1of 8

Which of these keywords is used to make a class?

Select one:
class
None of these
int
struct
Question 2
Answer saved
Marked out of 1.00
Flag question
Question text
What will be the output of the following program?
class Relational_operator {
public static void main(String args[])
{
int var1 = 5;
int var2 = 6;
System.out.print(var1 > var2);
}
}
Select one:
true
1
false
0
Question 3
Answer saved
Marked out of 1.00
Flag question
Question text
Which of the following jump statements will skip the remaining code within its b
ody?
Select one:
break
return
continue
exit
Question 4
Answer saved
Marked out of 1.00
Flag question
Question text
Which of the following converts the String s="Spoken Tutorial" into upper case?
Select one:
s=s.toUpper();
s=s.toUpperCase();
s=s.Upper();
s=s.UpperCase();
Question 5
Answer saved
Marked out of 1.00
Flag question
Question text
What will be the output of the function?

public void array()


{
int array_variable [] = new int[10];
for (int i = 0; i < 10; ++i)
{
array_variable[i] = i/2;
array_variable[i]++;
System.out.print(array_variable[i] + " ");
i++;
}
}
Select one:
0 1 2 3 4 5
1 2 3 4 5
0 1 2 3 4
1 2 3 4
Question 6
Answer saved
Marked out of 1.00
Flag question
Question text
What will be printed using following code block?
int[] a = {0,1,2,3,4,5,6,7};
System.out.println(a.length);
Select one:
9
6
8
7
Question 7
Answer saved
Marked out of 1.00
Flag question
Question text
What will be the output of the following program?
class ArithmeticDemo {
public static void main (String[] args)
{
int result;
result=-2 + 5 * 7- 7 / 2 % 5;
System.out.println("The result is: " + result);
}
}
Select one:
1
30
Compilation Error
The result is: 30
Question 8
Answer saved
Marked out of 1.00

Flag question
Question text
What will be the output of the following program?
class Scope3
{
public static void main(String args[])
{
for (int i=1;i<=3 ;i++ )
{
int y=1;
System.out.println("i="+i+" y="+y);
y++;
}
}
}
Select one:
None of these
i=1 y=1
i=2 y=1
i=3 y=1
i=1 y=1
i=2 y=2
i=3 y=3
i=1 y=1
i=1 y=1
i=1 y=1
Question 9
Answer saved
Marked out of 1.00
Flag question
Question text
What will be the output of the following program?
class string_class {
public static void main(String args[])
{
String obj = "I LIKE JAVA";
System.out.println(obj.length());
}
}
Select one:
9
11
12
10
Question 10
Answer saved
Marked out of 1.00
Flag question
Question text
What is the value stored in x in following lines of code?
int
x =
y =
x =

x, y, z;
0;
1;
y = z = 8;

Select one:
9
1
8
0
Question 11
Answer saved
Marked out of 1.00
Flag question
Question text
What will be the output of the following program?
class operators {
public static void main(String args[])
{
int x = 8;
System.out.println(++x * 3 + " " + x);
}
}
Select one:
27 9
27 8
24 9
24 8
Question 12
Answer saved
Marked out of 1.00
Flag question
Question text
What will be the value of obj in following line of code?
box obj;
Select one:
null
memory address of allocated memory of object
any arbitrary pointer
garbage value
Question 13
Answer saved
Marked out of 1.00
Flag question
Question text
How can we define more than one method in a class differentiated by method signa
ture?
Select one:
Method overloading
Method doubling
Method overriding
None of the mentioned
Question 14
Answer saved
Marked out of 1.00
Flag question
Question text
We use ______________ to create an object for the class.
Select one:

new keyword
non-static block
this keyword
dot operator
Question 15
Answer saved
Marked out of 1.00
Flag question
Question text
Which of the following statements is correct?
Select one:
true and false are numeric values 0 and 1.
true and false are non numeric values.
true and false are numeric values 1 and 0.
true is any non zero value and false is 0.
Question 16
Answer saved
Marked out of 1.00
Flag question
Question text
The default value of an object reference declared as an instance variable is ___
________.
Select one:
0.0
garbage value
0
null
Question 17
Answer saved
Marked out of 1.00
Flag question
Question text
What will be the output of the following program?
class booloperators {
public static void main(String args[])
{
boolean var1 = true;
boolean var2 = false;
System.out.println((var2 & var2));
}}
Select one:
true
1
false
0
Question 18
Answer saved
Marked out of 1.00
Flag question
Question text
What will be the output of the following program?
class Output{
public static void main(String args[])
{

int x , y;
x = 10;
x++;
--x;
y=x++;
System.out.println(x +" "+y);
}
}
Select one:
10 11
10 10
11 10
11 11
Question 19
Answer saved
Marked out of 1.00
Flag question
Question text
What will be the output of the following program?
class multipleAssignment
{
public static void main(String[] args) {
int i,j,k;
i=j=k=10;
System.out.println("i="+i+" j="+j+" k="+k);
}
}
Select one:
Compilation Error
i=0 j=0 k=10
i=0 j=0 k=0
i=10 j=10 k=10
Question 20
Answer saved
Marked out of 1.00
Flag question
Question text
_____________ is returned by greater than (>) and equal to (==) operator.
Select one:
Boolean
Integers
Floating - point numbers
None of the mentioned
Question 21
Answer saved
Marked out of 1.00
Flag question
Question text
We can use this keyword inside a constructor to call another constructor within
the same class. This is called __________________.
Select one:
Method overloading
Explicit constructor invocation
Constructor overloading
Method overriding
Question 22

Answer saved
Marked out of 1.00
Flag question
Question text
What will be the output of the following 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++;
}
}
}
Select one:
1 2 3 4 5 6 7 8 9 10
0 2 4 6 8
1 3 5 7 9
0 1 2 3 4 5 6 7 8 9
Question 23
Answer saved
Marked out of 1.00
Flag question
Question text
Point out the error in the following program.
1.class box {
2.int width;
3.int height;
4.int length;
5.}
6.class mainclass {
7.public static void main(String args[])
8.{
9.box obj = new box();
10.System.out.println(obj);
15.}
16.}
Select one:
Line number 9
Line number 10
No Error
Line number 6
Question 24
Answer saved
Marked out of 1.00
Flag question
Question text
Point out the error in the following code.
1.class box {
2.int width;
3.int height;
4.int length;

5.int volume;
6.void volume(int height, int length, int width) {
7.volume = width*height*length;
8. }
9. }
10.class Parameterized_method{
11.public static void main(String args[])
12. {
13. box obj = new box();
14. obj.height = 1;
15. obj.length = 5;
16. obj.width = 5;
17. obj.volume(3,2,1);
18. System.out.println(volume);
19. }
}
Select one:
Line number 6
Line number 7
Line number 18
None of these

You might also like