questionStatement
|
answerA
|
answerB
|
answerC
|
answerD
|
Identify the first line of a
constructor declaration in the following code? public class try_ques {
// A int current, step; public void cart(int strength) {
strength = strength + 1 ;//B
} public try_ques(int players, int stage) // C { setCurrent(players,stage); }
public void setCurrent(int value,int value2) {
current=value;
step=value2; }// D }
|
A
|
B
|
C
|
D
|
Given the following code, which
statements are true? Class One
{ private int one_value; }
class two extends one { int
two_value; }
|
Objects of class two have a field
named one_value.
|
Class two extends class one.
|
Both A and B.
|
None of the above.
|
Which one of these declarations is
a valid method declaration?
|
void func {/* ...
*/}
|
int func() {/*
... */}
|
boolean func(void) {/*
... */}
|
func(void) {/*
... */}
|
Which of the following is true
about enumumerations?
|
An enum type can implement
interfaces.
|
It allows sequential access to all
the elements stored in the collection.
|
An enum type can define
constructors.
|
All of the above.
|
Which of the following is a valid
statement?
|
int i[]=new int[1];
|
int i=new int;
|
int i=new int();
|
int i[]=new int();
|
Which of the following statements
is wrong? public class ques
{ // A public static void main (String[] args)
{ int i=0; final int b=0; int c=0;//1 i=i++;//2 b=b++;//3 c=c++;//4 }
}
|
1
|
2
|
3
|
4
|
Which of the following is not a
reserved keyword?
|
public
|
static
|
void
|
main
|
What will the output of the
following code: public class try_ques {
// A public static void
main(String[] args) { int b=0; try
{ char c='B'; b=(int)c; }
finally { System.out.println(b); } }
}
|
66
|
Compilation error
|
0
|
None of the above
|
What will be the output of the
following code? public class try_ques {
public static void main(String[] args) {
float i=(float)(1/2 + 3/2 + 0.1);
System.out.println(i); } }
|
1.1
|
1
|
2
|
1.5
|
Which of the following is not true
in Java?
|
A class can only extend one class.
|
The subclass of a non-abstract class
can be declared as abstract.
|
A final class can be abstract.
|
Every Java object has a public
method named length.
|
Tuesday, October 20, 2015
JAVA SAMPLE QUESTIONS
Labels:
TAP
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment