Top Banner
Lara Technology 9:30 AM – 1:30 PM Lara Technology 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: 25.A a1 =new A(); 26. A a2 =new A(); 27. A a3 =new A(); 28. System.out.print In(A.getInstance Count() ); www.laratechnology.com 080-41310124
32
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Q C PAPER

Lara Technology 9:30 AM – 1:30 PM Lara Technology

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: 25.A a1 =new A(); 26. A a2 =new A(); 27. A a3 =new A();

28. System.out.printIn(A.getInstanceCount() ); 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. D. A runtime error occurs when line 25 executes. E. Compilation fails because of an error on line 28. Ans:: B2.Program Given: 10. class Foo {

www.laratechnology.com 080-41310124

Page 2: Q C PAPER

Lara Technology 9:30 AM – 1:30 PM Lara Technology

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 (). 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 { } 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 {

www.laratechnology.com 080-41310124

Page 3: Q C PAPER

Lara Technology 9:30 AM – 1:30 PM Lara Technology

11. public One foo() { return this; } 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() { } B. public Two foo() { return this; }

C. public One foo() { return this; } D. public Object foo() { return this; } E. public Three foo() { return this; } Ans:: B,c,e5.Program

Given:

10. class One { 11. public One() { System.out.print(1); } 12. } 13. class Two extends One { 14. public Two(int i) { System.out.print(2); } 15. } 16. class Three extends Two {

www.laratechnology.com 080-41310124

Page 4: Q C PAPER

Lara Technology 9:30 AM – 1:30 PM Lara Technology

17. public Three() {super(5); System.out.print(3); } 18. } 19. public class Numbers{ 20. public static void main( String[] args) { new Three(); } 21. } What is the result when this code is executed?

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 { 17. String emplD = “0000”; 18. public Employee(String id) {super(“manu”) ; this.empID = id; } 19. } 20.

www.laratechnology.com 080-41310124

Page 5: Q C PAPER

Lara Technology 9:30 AM – 1:30 PM Lara Technology

21. public class EmployeeTest { 22. public static void main(String[] args) { 23. Employee e = new Employee(”4321”); 24. System.out.println(e.empID); 25. } 26. } 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. } 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.

www.laratechnology.com 080-41310124

Page 6: Q C PAPER

Lara Technology 9:30 AM – 1:30 PM Lara Technology

C. Compilation will always fail because of an error in line 7. D. Compilation will always fail because of an error in line 8. Ans::A8.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(”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.

www.laratechnology.com 080-41310124

Page 7: Q C PAPER

Lara Technology 9:30 AM – 1:30 PM Lara Technology

E. Compilation fails because of an error in line 22. Ans::B9.Program1. class TestA { 2. public void start() { System.out.println(”TestA”); } 3. } 4. public class TestB extends TestA { 5. public void start() { System.out.println(”TestB”); } 6. public static void main(String[] args) { 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::B10.Program11. class Alpha{12. public void foo(){System.out.println(“Afoo”);}13.}14. public class Beta extends Alpha{15. public void foo(){System.out.println(“Bfoo”);}16. public static void main (String args[]){

www.laratechnology.com 080-41310124

Page 8: Q C PAPER

Lara Technology 9:30 AM – 1:30 PM Lara Technology

17. Alpha a=new Alpha();18. Beta b=(Beta)a;19. a.foo();20. b.foo();What is the result?

A. Afoo AfooB. Afoo BfooC. Bfoo AfooD. Bfoo BfooE.

CompilationFailsF. An exception

is thrown at runtimeAns:: 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 class A{

public void main(){

System.out.print(“Gokul”);}

}class Manager{

www.laratechnology.com 080-41310124

Page 9: Q C PAPER

Lara Technology 9:30 AM – 1:30 PM Lara Technology

public static void main(String[] args){ System.out.print(“Krishna”);}

}A.Gokul B.Krishna C.Gokul , Krishna D.CTEAns:: B

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;

System.out.print(a2.i);

} }

A.CTE B.0 C.25 D.RTE

Ans:: C

15. Programfinal class F {

//some members}class G extends F{}A.CTS B.CTE C.RTEAns:: B

16.Programabstract class E {

www.laratechnology.com 080-41310124

Page 10: Q C PAPER

Lara Technology 9:30 AM – 1:30 PM Lara Technology

abstract static void test1();}A.CTS B.CTE C.RTEAns:: B17.Program

package com.lara;public class M2 {public static void main(String[] args)

{Double d1=new Double(10.09);double d2=d1.doubleValue();

System.out.println("done");}}

A.CTE B.10.09 C.done D.RTEAns::C

18.Program

public class A{

final int i = 10;public static void main(String[] args) {

A a1 = new A();

System.out.println(a1.i);

a1 = new A();}

}A.10 B.CTE C.0 D.RTEAns::A

19. Programclass P { int i=10;}class Q extends P { int i=20;}

www.laratechnology.com 080-41310124

Page 11: Q C PAPER

Lara Technology 9:30 AM – 1:30 PM Lara Technology

public class Zimbo {public static void main(String[] args) {

P p=new Q();System.out.println(

p.i);}

}

A.10 B.20 c.10,20 D.CTE

Ans::A// variable does not override

20.Programclass Manager10 {

public static void main(String[] args) {

E e1 = new F();test((F)e1);

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.CTEAns :: C

21.Program

public class D{public static void main(String[] args) {

double d=test(10);System.out.println(d);

www.laratechnology.com 080-41310124

Page 12: Q C PAPER

Lara Technology 9:30 AM – 1:30 PM Lara Technology

}static float test(int i){return 70;}}A.10 B.70 C.10,70 D.CTE E.RTEAns::B22.Programpublic class Mouse {

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.0Ans::A

23.Programclass A {

int i;void test1() {

System.out.println("A-test1");

}}class B extends A {

int j;void test2() {

System.out.println("B-test2");

www.laratechnology.com 080-41310124

Page 13: Q C PAPER

Lara Technology 9:30 AM – 1:30 PM Lara Technology

}}class Manager1 {

public static void main(String[] args) {

A a1 = new A();a1.test1();a1.i = 10;

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.RTSAns:: C

24.Program class Manager9 {public static void main(String[] args) {

D d1 = new F();E e1 = (E) d1;

System.out.println("done");

}}A.CTS B.RTS C.CTE D.doneAns::B

25.Programclass Manager11 {

www.laratechnology.com 080-41310124

Page 14: Q C PAPER

Lara Technology 9:30 AM – 1:30 PM Lara Technology

public static void main(String[] args) {

A a1 = new A();B b1 = (B)a1;

System.out.println("done");

}}A.CTS B.RTS C.CTE D.doneAns :: 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 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% abstract?True/False Ans:: false

www.laratechnology.com 080-41310124

Page 15: Q C PAPER

Lara Technology 9:30 AM – 1:30 PM Lara Technology

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?

A.Polymorphism B.Abstraction C.Interface D.Inheritance

Ans:: D

59.In which access level we can’t 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 Downcasting C.Overriding D.overloading Ans:: A and C

61.In which access levels we can use outside the class?

www.laratechnology.com 080-41310124

Page 16: Q C PAPER

Lara Technology 9:30 AM – 1:30 PM Lara Technology

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 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 software’s 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

www.laratechnology.com 080-41310124

Page 17: Q C PAPER

Lara Technology 9:30 AM – 1:30 PM Lara Technology

C.methods and constructors D.none of the above Ans:: methods

69.While Installing JDK,Which 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:: s71.Primitives are pass by value.true/false? Ans:: true72.In a Single package Is it possible to keep a

two main method?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 methods75.for interface we can’t create object?True/false.Ans:: S76..By using temporary variable we are avoiding class cast

www.laratechnology.com 080-41310124

Page 18: Q C PAPER

Lara Technology 9:30 AM – 1:30 PM Lara Technology

exception?True/FalseAns:: False77. 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:: no79.What is the default value for String?A.null B.abc C.String D.None Ans:: null80.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 can’t inherit sub class?

A.protected B.public C.default 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

www.laratechnology.com 080-41310124

Page 19: Q C PAPER

Lara Technology 9:30 AM – 1:30 PM Lara Technology

Ans:: class and datatype

84.How many keywords will be there in java?

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?

A.4 B.2 C.3 D.10 Ans:: 3

86.true is not a keyword?True/FalseAns:: false

87.For Derived datatypes by default what value ill be

assigning for derived objects?

A.0 B.True C.null D.none of the above

Ans:: null

88.Overloading Should have same return type?True/False

Ans:: false

89.By using which keyword we are doing object creation?

A.Object B.null C.True D.none of the above

Ans:: D new keywors

www.laratechnology.com 080-41310124

Page 20: Q C PAPER

Lara Technology 9:30 AM – 1:30 PM 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

92.class is an identifier(T/F)?

Ans:: F

93.public is a keyword(T/F)?

Ans:: True

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

96.How many ways we can set the path?

A.1 B.2 C.3 D.4

Ans:: 2 ways

97.class is the blue print for all similar objects?True/false

Ans true

www.laratechnology.com 080-41310124

Page 21: Q C PAPER

Lara Technology 9:30 AM – 1:30 PM Lara Technology

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

ANs false

www.laratechnology.com 080-41310124