OOP Flashcards

1
Q

ways to copy the values of one object into another in Java:

A
  • By constructor
  • By assigning the values of one object into another
  • By clone () method of Object class
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Is the mechanism of wrapping up of data and code action on the
methods together as a single unit.

A

Encapsulation

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

We can create classes inside a package and import it in our main class so that we can use that class in our program

A

true

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

It should start with the uppercase letter.
It should be an adjective such as
Runnable, Remote, ActionListener.
Use appropriate words, instead of
acronyms.

A

Interface

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

Usage of Java super Keyword:

A
  1. super can be used to refer immediate parent class instance variable.
  2. super can be used to invoke immediate parent class method.
  3. super() can be used to invoke immediate parent class constructor.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Rules for using of Static Variables:

A
  • Variables or methods belong to class rather than to any particular instance.
  • A static method cannot access a non-static variable of a class nor can directly invoke non-static method.
  • Static members can be applied without creating or referencing an instance of the class.
  • A static variable will be shared by all instances of that class which will result in only one copy.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

means that this method doesn’t return any value.

A

void

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

Java follows camel-case syntax for naming the class, interface, method,
and variable.

If the name is combined with two words, the second word will start with
uppercase letter always such as actionPerformed(), firstName,
ActionEvent, ActionListener, etc.

A

CamelCase

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

is used to denote constants. It can be used with variables,
methods, and classes.

A

Final keyword

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

is a method of out that can be used to print a line.

A

print

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

To achieve encapsulation in Java:

A
  • Declare the variables of a class as private.
  • Provide public setter and getter methods to modify and view the variables values.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

3 ways to initialize object:

A

Initialization through reference
Initialization through method
Initialization through a constructor

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

If the reference variable of Parent class refers to the object of Child class, it is known as

A

Upcasting

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

Importing Packages:

A
  • Importing Specific Class
    ex: import packagename.classname
  • Import Whole Package
    ex: import packagename.*
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

uses variables to define data fields and methods to define
actions, and provides methods of a special type, known as
constructors, which are invoked to create a new object.

A

class

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

is a pre-defined class that Java provides us and it holds some
useful methods and variables.

A

System

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

is represented by data fields with their current values.

A

The state of an object

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

It should be a lowercase letter such as
java, lang.
If the name contains multiple words, it
should be separated by dots (.) such as
java.util, java.lang.

A

Package

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

means that you can run this method without creating an instance
of Main.

A

static

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

is a way of thinking about and structuring a
program’s functionality.

A

programming paradigm

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

Static keyword is unacceptable to the following:

A
  • Class
  • Constructor
  • Local inner classes
  • Inner class methods
  • Instance variables
  • Local Variables
  • Interfaces
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

Rules in Creating Java Constructor:

A
  1. Constructor name must be the same as its class name
  2. A Constructor must have no explicit return type.
  3. 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
23
Q

means that anyone can access it.

A

public

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

specifies the accessibility or scope of a field,
method, constructor, or class.

A

access modifiers

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

two ways to overload the method in java:

A

Method Overloading: changing no. of arguments
Method Overloading: changing data type of arguments

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

is a block of code which only runs when it is called.

A

method

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

It should start with a lowercase letter
such as id, name.
It should not start with the special
characters like & (ampersand), $
(dollar), _ (underscore).
If the name contains multiple words,
start it with the lowercase letter
followed by an uppercase letter such as
firstName, lastName.
Avoid using one-character variables
such as x, y, z.

A

Variable

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
28
Q
  • The process by which objects can acquire the properties of
    objects of other class.
  • Provides reusability, like adding additional features to an existing
    class without modifying it.
A

Inheritance

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

is used to create an instance of the class. In other
words, it instantiates a class by allocating memory for a new object and
returning a reference to that memory.

A

New Keyword

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

Information can be passed to methods as parameter. act as
variables inside the method.

A

Parameters or Arguments

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
31
Q
  • Refers to the ability to process objects differently depending on
    their data type or class.
  • The ability to redefine methods to derived classes.
  • Request for an operation can be made without knowing which
    specific method should be invoked.
  • A task performed into different ways.
A

Polymorphism

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

is an instance of a class.

A

object

33
Q

Are variables declared within a class, it can be accessed within the whole class

A

Global Variables

34
Q
  • can be invoked without having an instance of the
    class.
  • can be used to refer to the common property of all
    objects
A

Static variable

35
Q

are those types of methods that don’t require
implementation for its declaration.

A

Abstract methods

36
Q

When a class inherits another class, it is known as

A

Single Inheritance

37
Q

Advantages of Encapsulation in Java

A

-By providing only a setter or getter method, you can make the class read-only or write-only.
- It provides you the control over the data.
- It is a way to achieve data hiding in Java because other class will not be able to access the data through the private data members.

38
Q

is a constructor that creates an object
using another object of the same Java class.

A

copy constructor

39
Q

When type of the object is determined at run-time

A

Dynamic binding

40
Q

If a class has multiple methods having same name but different in parameters, it is known as

A

Method Overloading.

41
Q

is a reference variable which is used to refer
immediate parent class object.

A

super keyword

42
Q
  • belongs to the class rather than the object of a class.
  • can be invoked without the need for creating an instance
    of a class.
A

Java Static Method

43
Q

Advantages of static variable

A

It makes your program memory efficient

44
Q

can have constructors like the regular class.

A

abstract class

45
Q

A variable which is created inside the class but outside the method is
known as an

A

Instance Variable

46
Q

represents an entity in the real world that can be distinctly
identified.

A

object

47
Q

The process of creating an Instance of a class so we can use it on our program.

A

Class Instantiation

48
Q

This constructor is
implemented by default by the Java compiler if there is no explicit constructor
implemented by the user for the class.

A

Default Constructor

49
Q

We can create multiple packages inside our java project, we can also reuse it in other projects if we choose to do so.

A

true

50
Q

Different ways to create object:

A

New Keyword
New Instance
Clone Method
Deserialization
By Factory method

51
Q

If a class has multiple methods having same name but different in
parameters, it is known as

A

Method Overloading.

52
Q

When there is a chain of inheritance, it is known as

A

Multilevel Inheritance

53
Q
  • Refers to the class itself.
  • Enables you to access global variables inside the class if you have
    the same variable names in a parameter.
A

This Keyword

54
Q

is a static variable within System that represents the output of your
program (stdout).

A

out

55
Q

New Keyword:

A
  • It is used to create the object.
  • It allocates the memory at runtime.
  • All objects occupy memory in the heap area.
  • It invokes the object constructor.
  • It requires a single, postfix argument to call the constructor
56
Q

is a template, blueprint, or contract that defines what an object’s
data fields and methods will be.

A

class

57
Q

It should start with the uppercase
letter.
It should be a noun such as Color,
Button, System, Thread, etc.
Use appropriate words, instead of
acronyms.

A

Class

58
Q

Are variables declared inside a method, condition, loops and any other block of
code, it can only be accessible within that block of code.

A

Local Variables

59
Q

is a technique of having more than one
constructor with different parameter lists.

A

Constructor overloading

60
Q

designed to perform initializing
actions, such as initializing the data fields of objects.

A

constructors

61
Q

has a unique identity, state, and behavior.

A

object

62
Q

methods used to protect your data and make your
code more secure.

A

Getters and Setters

63
Q

Usage of Method Overriding

A
  • Method overriding is used to provide the specific implementation of a method which is already provided by its superclass.
  • Method overriding is used for runtime polymorphism
64
Q
  • A constructor which has a specific number of parameters
  • used to provide different values to
    distinct objects.
A

parameterized constructor

65
Q
  • Class that is not used to create (instantiate) objects.
  • Designed to act as a base (to be inherited by other class).
  • Design concept in program development and provides a base upon
    which other classes are built.
  • Can only specify members that should be implemented by all
    inheriting classes.
  • It is the process of hiding the implementation details from the user.
  • Only the functionality will be shown to the user to reduce the
    complexity and increase efficiency.
A

Abstraction

66
Q

is an object-oriented programming technique that combines data
and instructions for processing that data into an object that can be used within
the program.

A

Object-Oriented Programming System(OOP)

67
Q

A class in Java can contain:

A
  • Fields
  • Methods
  • Constructors
  • Blocks
  • Nested class and interface
68
Q

Types of Inheritance in Java:

A

Single Inheritance
Multilevel Inheritance

69
Q

It is a full Abstract Class that implemented in other classes.

A

Interfaces

70
Q

acts as a non-access modifier in Java that is used
mainly to manage memory.

A

Static Keyword

71
Q

is a process in which a call to an overridden method is resolved at runtime rather than compile-time.

A

Runtime polymorphism

72
Q

It should start with lowercase letter.
It should be a verb such as main(),
print(), println().
If the name contains multiple words,
start it with a lowercase letter followed
by an uppercase letter such as
actionPerformed().

A

Method

73
Q

Advantage of Method:

A
  • Code Reusability
  • Code Optimization
74
Q

When type of the object is determined at compiled time
compiler doesn’t decide the method to be called.

A

Static binding

75
Q

is a group of similar types of classes, interfaces and sub-
packages.

A

Java Package

76
Q

It should be in uppercase letters such
as RED, YELLOW.
If the name contains multiple words, it
should be separated by an
underscore(_) such as MAX_PRIORITY.
It may contain digits but not as the first
letter.

A

Constant

77
Q

It is a rule to follow as you decide what to name your identifiers such as
class, package, variable, constant, method, etc.

A

Java Naming Convention

78
Q

If subclass (child class) has the same method as declared in the parent class, it is known as

A

method overriding