We have sent an email with your new password.


Oops Concepts In Java

30 Questions  I  By Srividya123
oops concepts in java
 oops concept in java

  
Changes are done, please start the quiz.


Question Excerpt

Removing question excerpt is a premium feature

Upgrade and get a lot more done!
1.  HAS-A relationships are based on inheritance, rather than usage.  
A.
B.
2.  The inheriting class cannot override the definition of existing methods by providing its own implementation.
A.
B.
3.  Ad hoc polymorphism is ____________.
A.
B.
C.
D.
4.  At run-time, a Java program is nothing more than objects ‘talking’ to ___________.
A.
B.
C.
D.
5.    An interface cannot have an inner class.  
A.
B.
6.  The ability to make changes in your implementation code without breaking the code of others who use your code is a key benefit of _______________.  
A.
B.
C.
D.
7.  A class is not an object. But it is used to construct objects.  
A.
B.
8.   A method defined in a superclass is redefined in a subclass with an identical method signature is called___________.
A.
B.
C.
D.
9.   Subclassing polymorphism is sometimes called “true polymorphism”.
A.
B.
10.  Method overloading is done during _______.
A.
B.
C.
D.
11.  Consider the code below and choose the correct option. class GameShape { public void displayShape() { System.out.println("displaying shape");    }    // more code }   class PlayerPiece extends GameShape { public void movePiece() { System.out.println("moving game piece");    }    // more code }   public class TestShapes {    public static void main (String[] args) {       PlayerPiece shape = new PlayerPiece();       shape.displayShape();       shape.movePiece();    } }  
A.
B.
C.
D.
12.    Array or collection of superclass references can be used to access a mixture of superclass and subclass objects.  
A.
B.
13.  Given below the sample code :   1   class Hotel { 2   public int bookings; 3   public void book() { 4   bookings++; 5   } 6   } 7   public class SuperHotel extends Hotel { 8   public void book() { 9   bookings--; 10  } 11  public void book(int size) { 12  book(); 13  super.book(); 14  bookings += size; 15  } 16  public static void main(String args[]) { 17  Hotel hotel = new Hotel(); 18  hotel.book(2); 19  System.out.print(hotel.bookings); 20  }}   How can we correct the above code ? (choose all that apply)  
A.
B.
C.
D.
14.  Consider the below code and choose the correct output. public class Main { public int a; public long b; public void test(long  b) { System.out.println("long b"); } public void test(int a) { System.out.println("int a"); } public static void main(String[] args) {                 Main e=new Main();         e.test(9*1000000000);               }   }  
A.
B.
C.
D.
15.  Aggregation is a special form of association.  
A.
B.
16.  Examples of class are( choose 3)  
A.
B.
C.
D.
E.
17.     The relation between Car and Owner or BankAccount and Customer is example for  
A.
B.
C.
D.
18.  Polymorphism is one interface with __________.  
A.
B.
C.
D.
19.  Every class in Java is a subclass of class _____________.  
A.
B.
C.
D.
20.  Given below the sample code :   class Hotel { public int bookings=2; public void book() { bookings++; } }   public class SuperHotel extends Hotel { public void book() { bookings--; }   public void book(int size) { book(); super.book(); bookings += size; }   public static void main(String args[]) { SuperHotel Shotel = new SuperHotel(); Shotel.book(2); System.out.print(Shotel.bookings); } }   Find the output of the following code :  
A.
B.
C.
D.
21.  The benefits of the Object Orientation are: ( choose two )
A.
B.
C.
D.
22.  In OO, the concept of IS-A is based on  
A.
B.
C.
D.
23.  If you do not have access to the source code for a class, but you want to change the way a method of that class works, then could you use subclassing to do that that is to extend the “bad” class and override the method with your own better code?  
A.
B.
24.  Interfaces are fast as it requires extra indirection to find corresponding method in the actual class.  
A.
B.
25.  Given the following sample code:   public class Example5{       public float Twin(float a, float b) {...         } public float Twin(float a1, float b1) { ...}           }   How can we correct the above code ?(choose two)  
A.
B.
C.
D.
26.  Given below the sample code :   import java.io.IOException;   class Example7 { public float Twin(float x, float y) throws IOException { return 0; } }   class SubExample7 extends Example7 { float Twin(float x, float y) { return 0; } }     How can we correct above code ? (choose two)  
A.
B.
C.
D.
27.  The two most common reasons to use inheritance are( choose 2)
A.
B.
C.
D.
28.  In Java, the actual method executed is determined by the type of the object and not the type of the reference.  
A.
B.
29.  A class can inherit instance variables and methods from a more abstract superclass.
A.
B.
30.   The methods in class object are(choose four)  
A.
B.
C.
D.
E.
F.
Back to top

Removing ad is a premium feature

Upgrade and get a lot more done!
Take Another Quiz