Documente Academic
Documente Profesional
Documente Cultură
1. Program
1. public class A
{
2.
3. private static
int counter = 0;
4.
5. public static
int
getInstanceCount()
{
6. return
counter;
7. }
8.
9. public A() {
10. ++counter;
11. }
12.
13. }
Given this code
from Class B:
www.laratechnology.com
080-41310124
25.A a1 =new
A();
26. A a2 =new
A();
27. A a3 =new
A();
28.
System.out.printIn(
A.getInstanceCoun
t() );
What is the
result?
A. Compilation
of class A fails.
B. Line 28 prints
the value 3 to
System.out.
C. Line 28 prints
the value 1 to
System.out.
Lara Technology
D. A runtime
error occurs when
line 25 executes.
E. Compilation
fails because of an
error on line 28.
Ans:: B
2.Program
Given:
10. class Foo {
11. static void
alpha() { /* more
code here */ }
12. void beta() { /*
more code here
*/ }
13. }
Which two are
true? (Choose two.)
A. Foo.beta () is a
valid invocation of
beta ().
www.laratechnology.com
080-41310124
B. Foo.alpha () is a
valid invocation of
alpha ().
C. Method beta ()
can directly call
method alpha ().
D. Method alpha ()
can directly call
method beta ().
3.Program
Which Man class
properly represents
the relationship
Man is a best
Friend who is a
Dog?
A. class Man
extends Dog { }
B. class Man
implements Dog
{}
Lara Technology
C. class Man
{ private
BestFriend dog; }
D. class Man
{ private Dog
bestFriend; }
E. class Man
{ private
Dog<bestFriend>
}
F. class Man
{ private
BestFriend<dog> }
Ans::A
4.Program
41. Given:
10. class One {
11. public One
foo() { return
this; }
www.laratechnology.com
080-41310124
12. }
13. class Two
extends One {
14. public One
foo() { return
this; }
15. }
16. class Three
extends Two {
17. // insert
method here
18. }
Which three
methods, inserted
individually,
correctly complete
the Three
class? (Choose
two.)
A. public void foo()
{}
Lara Technology
Lara Technology
A. 1
B. 3
C. 123
D. 321
E. The code
rims with no
output.
Ans::C
6.Program
11. class Person
{
12. String name
= No name;
13. public
Person(String nm)
{ name = nm; }
14. }
15.
16. class
Employee extends
Person {
www.laratechnology.com
080-41310124
Lara Technology
What is the
result?
A. 4321
B. 0000
C. An exception is
thrown at runtime.
D. Compilation fails
because of an error
in line 18.
Ans::A
7.Program
Given:
1. class
SuperClass {
2. public A getA()
{
3. return new A();
4. }
5. }
www.laratechnology.com
080-41310124
6. class SubClass
extends
SuperClass {
7. public B getA()
{
8. return new B();
9. }
10. }
Which is true?
A. Compilation will
succeed if A
extends B.
B. Compilation will
succeed if B
extends A.
C. Compilation will
always fail
because of an
error in line 7.
D. Compilation will
always fail because
Lara Technology
of an error in line
8.
Ans::A
8.Program
11. class Cup
{}
12. class
PoisonCup extends
Cup { }
21. public void
takeCup(Cup c) {
22. if(c
instanceof
PoisonCup) {
23.
System.out.println(
Inconceivable!);
24. } else if(c
instanceof Cup) {
25.
System.out.println(
www.laratechnology.com
080-41310124
Dizzying
intellect!);
26. } else {
27.
System.exit(0);
28. }
29. }
And the execution
of the statements:
Cup cup = new
Cup();
takeCup(cup);
What is the
output?
A. Inconceivable!
B. Dizzying
intellect!
C. The code runs
with no output.
D. An exception is
thrown at runtime.
Lara Technology
E. Compilation fails
because of an error
in line 22.
Ans::B
9.Program
1. class TestA {
2. public void
start()
{ System.out.printl
n(TestA); }
3. }
4. public class
TestB extends
TestA {
5. public void
start()
{ System.out.printl
n(TestB); }
6. public static void
main(String[] args)
{
www.laratechnology.com
080-41310124
7. ((TestA)new
TestB()).start();
8. }
9. }
What is the result?
A. TestA
B. TestB
C. Compilation
fails.
D. An exception is
thrown at runtime.
Ans::B
10.Program
11. class Alpha{
12.
public
void
foo()
{System.out.printl
n(Afoo);}
13.}
14. public class
Beta
extends
Alpha{
Lara Technology
15.
public
void
foo()
{System.out.printl
n(Bfoo);}
16. public static
void main (String
args[]){
17. Alpha a=new
Alpha();
18.
Beta
b=(Beta)a;
19. a.foo();
20. b.foo();
What is the result?
A. Afoo Afoo
B. Afoo Bfoo
C. Bfoo Afoo
D. Bfoo Bfoo
E.
CompilationFails
F.
An
exception is thrown
at runtime
Ans:: A
11. What is the
default value of
local primitive
double value?
A. 0
B. null C.
0.0 D. 1 E. No
Default value.
Ans:: E
12.inside the
abstract class can
we keep private
methods as fully
implemented?(Y/N)
Ans:: Y
13.Program
www.laratechnology.com
080-41310124
Lara Technology
class A
{
public void
main()
{
System.out.
print(Gokul);
}
}
class Manager
{
public static
void
main(String[]
args)
{
System.out.prin
t(Krishna);
}
}
A.Gokul B.Krishna
C.Gokul , Krishna
D.CTE
Ans:: B
www.laratechnology.com
080-41310124
14.Program
class A{ int i; }
class B
extends A{ int i
= 25; }
class
Manager
{
public static
void main(String[]
args){
A a1 = new
B();
A a2 = new
A();
a2.i = a1.i =
new B().i;
Lara Technology
System.out.print(a
2.i);
} }
A.CTE B.0 C.25
D.RTE
Ans:: C
15. Program
final class F {
//some
members
}
class G extends F
{
}
A.CTS B.CTE
C.RTE
Ans:: B
16.Program
abstract class E {
abstract static
void test1();
}
A.CTS B.CTE
C.RTE
Ans:: B
17.Program
package
com.lara;
public class M2
{
public static
void
main(String[]
args)
{
Double d1=new
Double(10.09);
double
d2=d1.doubleV
alue();
System.out.println(
"done");
www.laratechnology.com
080-41310124
Lara Technology
}
}
A.CTE B.10.09
C.done D.RTE
Ans::C
18.Program
public class A{
final int i =
10;
public static void
main(String[]
args) {
A a1 = new
A();
System.out.print
ln(a1.i);
a1 = new
A();
}
}
A.10 B.CTE C.0
D.RTE
www.laratechnology.com
080-41310124
Ans::A
19. Program
class P { int
i=10;}
class Q extends P {
int i=20;}
public class Zimbo
{
public static void
main(String[] args)
{
P p=new Q();
System.out.prin
tln(p.i);
}
}
A.10 B.20 c.10,20
D.CTE
Ans::A// variable
does not
override
20.Program
Lara Technology
class Manager10 {
Ans :: C
public static
void main(String[]
args) {
E e1 = new
F();
test((F)e1);
21.Program
System.out.println(
"done");
}
static void
test(F f1) {
System.out.println(
"test(F)");
}
}
A.done b.done ,
test(F)
c.test(F),done
D.test(F) E.CTE
www.laratechnology.com
080-41310124
public class D
{
public static void
main(String[] args)
{
double d=test(10);
System.out.println(
d);
}
static float test(int
i)
{
return 70;
}}
A.10 B.70 C.10,70
D.CTE E.RTE
Ans::B
22.Program
public class Mouse
{
Lara Technology
static short
test(int i)
{
return (byte)
(double)i;
}
public static
void main(String[]
args)
{
byte b=28;
System.out.println(
test(b));
}
}
A.28 B.CTE
C.RTE D.0
Ans::A
23.Program
class A {
int i;
void test1() {
www.laratechnology.com
080-41310124
System.out.println(
"A-test1");
}
}
class B extends A {
int j;
void test2() {
System.out.println(
"B-test2");
}
}
class Manager1 {
public static
void main(String[]
args) {
A a1 = new
A();
a1.test1();
a1.i = 10;
Lara Technology
System.out.println(
a1.i);
B b1 = new
B();
b1.test1();
b1.i = 10;
b1.test2();
b1.j = 20;
System.out.println(
b1.i);
System.out.println(
b1.j);
}
}
A.CTS B.CTE C.RTS
Ans:: C
24.Program
class Manager9
{
www.laratechnology.com
080-41310124
Lara Technology
System.out.println(
"done");
}}
A.CTS B.RTS
C.CTE D.done
Ans :: B
51.What is the
default editor in
java?
A.Edit plus
B.Notepad
C.Eclipse D.Net
beans
Ans:: notepad
52.Is it possible to
compiler will keep
default constructor
in a Simple Hello
www.laratechnology.com
080-41310124
world Program?
Ans:: s
53.What is the
default value for
Character? Ans::
Space
A.Space B.a C.i
D.No default value
54.Is it possible to
keep Private
constructor in a
class? Ans:: yes
55.In abstract class
When we are
implementing fully
abstract methods
no concrete
methods then It
will achieve 100%
Lara Technology
abstract?True/False
Ans:: false
56.Final methods
are Overriding
methods?
True/False Ans::
false
57.Is a
relationship also
called as
---------Ans::
inheritance
A.Polymorphism
B.Inheritance
C.Encapsulation
D.Abstraction
58.Which Concept
will achieve
Reusabality?
www.laratechnology.com
080-41310124
A.Polymorphism
B.Abstraction
C.Interface
D.Inheritance
Ans:: D
59.In which access
level we cant use
outside the class?
Ans:: private
A. private B. public
C. protected D.
default
60.What are the
two things
internally
happening when
we are achieving
polymorphism?
A.Auto upcasting
B.Explicit
Lara Technology
Downcasting
C.Overriding
D.overloading
Ans:: A and C
61.In which access
levels we can use
outside the class?
A.Private B.Public
C.Protected
D.Default Ans::
public ,protected
AND default
62.Is it possible to
keep Constructor
inside the abstract
class? Ans:: s
63.Without object
creation is it
possible to keep
www.laratechnology.com
080-41310124
Constructor inside
the class? Ans:: s
64.By Using which
keyword we are
Mentioning current
class ?
A.Private B.this
C.Public D.super
Ans:: this
65.Local variables
are storing in heap
memory?True/False
Ans:: false
66.Is it possible to
keep a method
with the name as
class name? Ans::
s
67.While installing
JDK,Which
Lara Technology
softwares are
Optional?
A.Source code
B.PublicJRE
C.Demos
D.Development
tools
Ans:: A ,B and C
68.Which one are
executable block?
A.Methods B.
Constructors
C.methods and
constructors
D.none of the
above Ans::
methods
69.While Installing
JDK,Which
www.laratechnology.com
080-41310124
Softwares are
mandatory?
A.Edit plusu
B.PublicJRE
C.Windows XP
D.Development
tools Ans:: D
70.Is it possible to
have more than
one reference to
the same object?
Ans:: s
71.Primitives are
pass by
value.true/false?
Ans:: true
72.In a Single
package Is it
possible to keep a
two main method?
Lara Technology
True/FalseAns::
true
73. In a empty
class,How many
members will be
there?
A.3 B.1 C.2
D.0Ans:: 1
74. private
methods are
similar to as?
A.non-final
methods B.final
methods C.Default
methods D.none of
the above Ans::
final methods
75.for interface we
cant create
object?True/false.
Ans:: S
www.laratechnology.com
080-41310124
76..By using
temporary variable
we are avoiding
class cast
exception?
True/FalseAns::
False
77. Cyclic calling
is happening
in
A. methods B.
constructors C.
methods and
constructors
D.none of the
above Ans::
methods
78.Is it possible to
keep abstract
constructor in a
class? Ans:: no
Lara Technology
79.What is the
default value for
String?
A.null B.abc
C.String D.None
Ans:: null
80.In which access
level we can use
outside the
package?
A.Private B.Public
C.Protected
D.Default Ans::
pubic and
protected
81. Which method
cant inherit sub
class?
A.protected
B.public C.default
www.laratechnology.com
080-41310124
D.none of the
above
Ans:: non of these
82.Static methods
are storing in
which memory?
A.stack B.heap
C.Object D.None
Ans:: heap
83.String is a
.
A.class B.datatype
C.keyword
D.Identifier
Ans:: class and
datatype
84.How many
keywords will be
there in java?
Lara Technology
A. 54 B. 64 C. 52
D. none of the
aboveAns:: 52
85.How many
steps it will gtake
to compose every
program in java?
Ans:: null
88.Overloading
Should have
same return
type?True/False
Ans:: false
86.true is not a
keyword?
True/FalseAns::
false
87.For Derived
datatypes by
default what value
ill be assigning for
derived objects?
A.Object B.null
C.True D.none
of the above
www.laratechnology.com
080-41310124
Ans:: D new
keywors
Lara Technology
90.Which access
level we will
use wider than
protected?
Ans:: public
A.private B.Default
C.Public D.none
91.Is it mandatory
to create object for
Static variables?
Ans:: false
94.What is the
argument of main
method?
A.int B.String
C.String[ ] D.None
of the above
Ans:: String[]
95..Can we declare
local variable
outside a method?
Ans:: No
92.class is an
identifier(T/F)?
Ans:: F
93.public is a
keyword(T/F)?
Ans:: 2 ways
Ans:: True
www.laratechnology.com
080-41310124
Lara Technology
Ans true
98.When we are
inheriting from one
class to another
class which
keyword we ill use?
A.new B.public
C.extends D.null
Ans extends
99. Is it required
to initialize the
value for local
variable?
Ans yes
100.What is the
default value for
Boolean?
A.True B.False
C.Null D.no value
www.laratechnology.com
080-41310124
ANs false