Chapter3 (1)

Share Embed Donate


Short Description

html...

Description

1. 2. 3. 4. 5. 6.

Interface A{ public void method();} … Test implements A,B © Compile successfully i)Constructors can be abstract ii) static iii) private (e)all are false Abstract final class Parent i) A class cannot be abstract (b)1,2 alone 3 is wrong Class SuperClass{ static void display(){sop(“hello super class”) © compile time error Interface A{ public void method1();} … Test implements A,B© Compile successfully Class A{ public void display(int i){ sop(“printing value of integer:”+i); byte mybyte=19 (b) printing value of integer:19 7. Package com.first Class A{ public void display(int i){ sop(“High I am Parent”); © compilation error 8. Interface myInterface{void show();void set();void just();} © compilation error 9. class A{ int i=10;public void printValue(){ System.out.println("Parent-A");} ans: Value-B 10 10. Interface myinter1{void display();}interface myinter1 extends myinter1,myinter2{...(b) yes code will compile 11. Redefining the instance method (c)method overriding 12. Public class Primes2{ {2,7,5,3} Arrays.sort (d)compilation fails 13. Class A {.. public static void display(){sop(“Hi I am Parent”); (a) hi i am parent 14. Class MyClass{ void add(int i,int ti){// I will do later} (a)True 15. Interface DisplayStack{void display();} class Parent{protected void display(){ (b) reduce the visibility inherited 16. Class Parent { final static public void display(){ 1. Static method cannot .. 2. 2.parent class final method cannot.. 3. Method can be final and static (c)1,2,3 are correct is wrong 17. Class overload{ int x; double y; (d) Compilation error 18. Public class inheritance_demo {... obj.i=1; obj.j=2;obj.display(); (c)compilation error 19. 1.Parent obj=new child() 2.Parent obj=new Parent() © 1,2,3 correct 4 wrong 20. Class Super{public int getLength()(return 4;) Super sooper (d) compilation error 21. which declaration prevents creating subclass? c) final public class FooBar() 22. abstract class Parent{..............obj.display();}--d)incorrect WRONG...a)1,2 correct and 3,4 incorrect (PROBABLY) 23. Keyword used to access the member of base class from sub--b)super 24. Which keywords cannot come together? Final static,,,abstract..private....b)all are correct 25. Consider the following statements-1)cons can be asbt,ii)static can be abst,iii)pri metd -(e) all are false 26. Which of this supported by method overriding c)polymorphism 27. How do you define class named exam1 so that it cannot be subclassed

d) final

class exam1() 28. If we want subclasses in any package to have access to members of a superclass.-c)protected 29. Public class Exam1{psvm(); ContactEmployee arun=new ContactEmployee();arun.freeTime();}} a)its time out zone 30. Class Parent{ protected void display(){ sop (“Parent display method”) child{public void display (){} a) this is example of overriding 31. Class superclass{void displaysuper().....subclawhen ss1()} d)compile time error 32. Class parent{ in i; void display(){sop(i)}...obj.display()} c)compile error 33. Class A{ protected int i=10;} class B extends A{protected int i=15;} Output: i=10 34. Class Base{int i=99; public void amethod() (b)Derived amethod() 99 Derived amethod() 35. Public Class Greek{int i=1;public int get1()......}class arabik extends greek….a)1sub2 36. Public interface Foo{ int k;} which is true? 1. Final int k=4… b) statement 1,2,3 in the options are replace the statement 4

37. Public class Test{pvsm{ print(10,10);} private static void print(int i, longl)

© compilation

error because of ambiguous method call 38. Import java util * public class primes2{....public int compare(object 01,object 02)---------------------d)compilation fails 39. Interface Animal{ void soundOff(){ class elephant implements Animals{

(d)

new alpha1().get(“veggle”).soungOff(); 40. Package abc;public class animal{ public animal().......Animal a =new cat();}----D) inside animal 41. Code compile successfully……….myinter{ int x; abstract void display();x=10 implementing display method---c)1-abstract,2-class,3-extends 42. interface myinter{ void display();}class A implements myinter{ public void display() {System.out.println("Implementing");public class Test2{ public static void main(String args[]) A obj1=new A();obj1.display(); }-----a)implimanting display method is wrong 43. Which of the following are incorrect? ---c)private members cab be inherited by subclass 44. Public abstract class Test{ public abstract void methodA();sop(“hello”);replace,remove--b)statement 1,3 45. When an interface is implemented by abstract ,the abstract class must provide...b)False 46.

View more...

Comments

Copyright ©2017 KUPDF Inc.
SUPPORT KUPDF