0% found this document useful (0 votes)
69 views5 pages

Method Overriding in Java Explained

The document contains questions about object-oriented programming concepts in Java including polymorphism, inheritance, encapsulation, and constructors. Method overriding is an example of compile time polymorphism. A constructor is automatically executed when an object is created to initialize attributes. Private members of a base class are accessible but not directly in a derived class.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
69 views5 pages

Method Overriding in Java Explained

The document contains questions about object-oriented programming concepts in Java including polymorphism, inheritance, encapsulation, and constructors. Method overriding is an example of compile time polymorphism. A constructor is automatically executed when an object is created to initialize attributes. Private members of a base class are accessible but not directly in a derived class.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

1. Which of the following is a type of polymorphism in Java?

= Compile time polymorphism

2. Method overriding is combination of inheritance and polymorphism?

= TRUE

3. Procedural Programming is a technique of solving a problem and breaking it


down into smaller parts and solving each of the smaller problems.

= PROCEDURAL PROGRAMMING

4. True or False: This line of code is correct System.out.println("Hi!");

= TRUE

5. Where does a java program start executing instructions from:

= MAIN METHOD

6. Construct – a method that is automatically executed when an object is created.


This method is used to initialize the attributes.

= FALSE

7. final Method: a method that cannot be overridden

= TRUE

8. This – contains a reference to the current object being constructed

= FALSE

9. a variable that is only accessible within a class where it is declared

= PRIVATE VARIABLE
10. Class Variables are variables stored in the class and are available to all objects
of a class or objects of other classes if access is permitted

= TRUE

11. In Inheritance, the programmer can change one part of the code without affecting
other parts

= FALSE

12. Which among the following would destroy the encapsulation mechanism if it was
allowed in programming?

= Using access declaration for private members of base class

13. What type of inheritance does Java have?

= Single Inheritance

14. In Encapsulation, Class variables can be made read-only or write-only

= TRUE

15. If data members are private, what can we do to access them from the class
object?

= Create public member functions to access those data members

16. The private members of the base class are visible in derived class but are not
accessible directly.

= TRUE

17. If base class contains 2 nested classes, will it be possible to implement single
level inheritance?

= YES ALWAYS

18. Which concept will result in derived class with more features (consider maximum
3 classes)?
= MULTIPLE INHERITANCE

19. Which amongst the following is true for hybrid inheritance?

= Constructor calls are usual

20. If a derived class object is created, which constructor is called first?

= BASE CLASS CONSTRUCTOR

2ND ATTEMPT

1. As a blueprint is a design for a house, a class is a design for a:

= OBJECT

2. Which concept of Java is a way of converting real world objects in terms of


class?

= ABSTRACTION

3. Which of the following is a mechanism by which object acquires the properties of


another object?

= INHERITANCE

4. How do I print out numbers on JAVA?

= System.out.println("#");
Other choices:
= System.out.println(#);
= System.out.println(false);
= System.out.println('#');

5. ________ – a method that is automatically executed when an object is created.


This method is used to initialize the attributes.

= CONSTRUCTOR
6. Local Variables are variables used in a method

= TRUE

7. Class Variables are variables stored in each object of a class, usually referred to
as the non-static member fields of a class.

= FALSE

8. this can be used to refer current class instance variable.

= TRUE

9. _________– used to change or access the private data in an object.

= Standard Methods

10. Encapsulation is the way to add functions in a user defined structure.

= FALSE

11. If data members are private, what can we do to access them from the class
object?

= Create public member functions to access those data members

12. While using encapsulation, which among the following is possible?

= Data member's data type can be changed without changing any other code

13. How can Encapsulation be achieved?

= Using Access Specifiers

14. Which among the following best describes the Inheritance?

= Using the data and functions into derived segment

15. Which among the following is true?


= Java doesn't support multiple inheritance

16. Which among the following is false for single level inheritance?

= There can be more than 2 independent classes involved in single inheritance

17. Which programming language doesn't support multiple inheritance?

= JAVA

You might also like