OOP Flashcards

1
Q

A ____, in the context of Java, are templates that are used to create objects, and to define object data types and methods. Core properties include the data types and methods that may be used by the object

A

class

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

A ____ can also be defined as a blueprint from which you can create an individual object.

A

class

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Any entity that has state and behavior is known as an _____

A

object

ex. a chair, pen, table, keyboard, bike, etc. It can be physical or logical.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

An Object can be defined as an instance of a class.

True or False

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

An _____ contains an address and takes up some space in memory.

A

Object

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

OOPs makes development and maintenance easier whereas in a procedure-oriented programming language it is not easy to manage if code grows as project size increases.

True or False

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

In OOPs data can be accessed from anywhere, whereas in a procedure-oriented programming language a global data can be hidden.

True or False

A

FALSE

OOPs provides data hiding whereas in a procedure-oriented programming language a global data can be accessed from anywhere.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

A _____ is a blueprint from which individual _____ are created.

A

A class is a blueprint from which individual objects are created.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

A _________ is called when a instance of the object is created.

A

constructor

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

When a constructor is created, _____ is allocated for the object.

A

memory

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

When an object is created, compiler makes sure that constructors for all of its subobjects (its member and inherited objects) are called.

True or False

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

A Constructor name does not have to be same same as its class name

True or False

A

False

Constructor name must be the same as its class name

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

A Constructor must have no explicit return type

True or False

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

A Java constructor can be abstract, static, final, and synchronized

A

False

A Java constructor cannot be abstract, static, final, and synchronized

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What are the two types of constructors?

A
  • Default Constructor
  • Parameterized Constructor
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

The _____ ________ is a no-args constructor that the Java compiler inserts on your behalf; it contains a default call to super(); which is the default behavior.

A

default constructor

17
Q

The following is an example of type of contructor type?

public Bicycle() {

gear = 1;

cadence = 10;

speed = 0;

}

A

Default Constructor or No-Argument Constructor

Bicycle yourBike = new Bicycle(); invokes the no-argument constructor to create a new Bicycle object called yourBike.

18
Q

a _____ ________ is added by the compiler when there is no constructor declared in the class.

A

default constructor

19
Q

What happens to the following constructor when compiled?

class Bike {

}

A

class Bike {

Bike(){}

}

20
Q

A constructor which has a specific number of parameters is called a __________ _________

A

Parameterized Constructor

21
Q

This the below class has an example of what type of constructor?

class Student4{

int id;

String name;

Student4(int i,String n){

id = i;

name = n;

}

void display(){System.out.println(id+” “+name);}

public static void main(String args[]){

Student4 s1 = new Student4(111,”Karan”);

Student4 s2 = new Student4(222,”Aryan”);

s1. display();
s2. display();

}

}

A

parameterized constructor

22
Q

In Java, a constructor is just like a ______ but without return type.

A

method

23
Q

A class cannot be overloaded like a method.

True or False

A

False

A class can be overloaded

24
Q

_________ ___________ in Java is a technique of having more than one constructor with different parameter lists.

A

Constructor overloading

25
Q

When constructors are overloaded each constructor is setup to perform a seperate task. They are differentiated by the compiler by the number of ________ in the list a and their _____.

A

When constructors are overloaded each constructor is setup to perform a seperate task. They are differentiated by the compiler by the number of parameters in the list a and their types.

26
Q

A method must have a return type

True or False

A

True

27
Q

The method name may or may not be same as the ____ name.

A

class

28
Q

The method is invoked ________

A

explicitly

29
Q

The method can be provided by the compiler

True or False

A

False

The method is not provided by the compiler in any case.

30
Q

A method is used to _______ the behavior of an object.

A

expose

31
Q

A constructor is used to ________ the state of an object.

A

Initialize

32
Q

Can a constructor have a return type

True or False

A

False

A constructor must not have a return type.

33
Q

The constructor is invoked ______.

A

implicitly

34
Q

The Java compiler provides a default _________ if you don’t have any constructor in a class.

A

constructor

35
Q

The constructor name must be same as the class name.

True or False

A

True