Java Interview Questions Flashcards
What is a class?
- A blueprint or outline/ template used for creating objects. (and to define object data types and methods
- doesn’t consume any space in memory.
What is an object?
- an instance of a class
- Any entity that has state and behavior For example a chair, pen, table, keyboard, bike, etc. It can be physical or logical.
- An ______ contains an address and takes up some space in memory.
- _____can communicate without knowing the details of each other’s data or code. The only necessary thing is the type of message accepted and the type of response returned by the objects.
5*
- Example: A dog is an object because it has states like color, name, breed, etc. as well as behaviors like wagging the tail, barking, eating, etc.
any entity that has ____ and behavior is an ____
state, object
An _____ contains an address and takes up _____ in __________.
object, space, memory
____ can communicate without knowing the ____ of each other’s ____ or code. The only necessary thing is the ____ of message accepted and the type of ____ returned by the objects.
Objects, details, data, type, response
In java, a _____ is just like a method but without the ____ type.
constructor, return
_____ _____ in Java is a technique of having more than one _____ with different ____ ____. They are arranged in a way that each ____ performs a different ___. They are differentiated by the compiler by the number of parameters in the list and their ____.
Constructor overloading in Java is a technique of having more than one constructor with different parameter lists. They are arranged in a way that each constructor performs a different task. They are differentiated by the compiler by the number of parameters in the list and their types.
A constructor is used to ____ the state of an ____.
initialize, object
- A constructor is used to ___ the state of an object.
- A constructor must not have a ____ type.
- The constructor is ____ ____.
- The Java ___ provides a ____ constructor if you don’t have any constructor in a class.
- The constructor name must be same as the class name.
- A constructor is used to initialize the state of an object.
- A constructor must not have a return type.
- The constructor is invoked implicitly.
- The Java compiler provides a default constructor if you don’t have any constructor in a class.
- The constructor name must be same as the class name.
The constructor is ____ ____.
invoked, implicitly
- A method is used to ____ the behavior of an object.
- A method must have a ___ type.
- The method is invoked ____.
- The method is ___ provided by the compiler in any case.
- The method name may or may not be same as ____ name.
- A method is used to expose the behavior of an object.
- A method must have a return type.
- The method is invoked explicitly.
- The method is not provided by the compiler in any case.
- The method name may or may not be same as class name.
A method is used to ____ the behavior of an object.
expose
The method is invoked ____.
explicitly.
in a method, the method ___ may or may not be the same as a ___.
name, class.
What is Object oriented programming?
- it is a methodology or paradigm to design a program using Classes and Objects
- It simplifies the software development and maintenance by providing some concepts:
classes, objects, abstraction, encapsulation, inheritance, polymorphism