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
two ways to overload the method in java:
Method Overloading: changing no. of arguments Method Overloading: changing data type of arguments
26
is a block of code which only runs when it is called.
method
27
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.
Variable
28
- 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.
Inheritance
29
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.
New Keyword
30
Information can be passed to methods as parameter. act as variables inside the method.
Parameters or Arguments
31
- 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.
Polymorphism
32
is an instance of a class.
object
33
Are variables declared within a class, it can be accessed within the whole class
Global Variables
34
- can be invoked without having an instance of the class. - can be used to refer to the common property of all objects
Static variable
35
are those types of methods that don’t require implementation for its declaration.
Abstract methods
36
When a class inherits another class, it is known as
Single Inheritance
37
Advantages of Encapsulation in Java
-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
is a constructor that creates an object using another object of the same Java class.
copy constructor
39
When type of the object is determined at run-time
Dynamic binding
40
If a class has multiple methods having same name but different in parameters, it is known as
Method Overloading.
41
is a reference variable which is used to refer immediate parent class object.
super keyword
42
- belongs to the class rather than the object of a class. - can be invoked without the need for creating an instance of a class.
Java Static Method
43
Advantages of static variable
It makes your program memory efficient
44
can have constructors like the regular class.
abstract class
45
A variable which is created inside the class but outside the method is known as an
Instance Variable
46
represents an entity in the real world that can be distinctly identified.
object
47
The process of creating an Instance of a class so we can use it on our program.
Class Instantiation
48
This constructor is implemented by default by the Java compiler if there is no explicit constructor implemented by the user for the class.
Default Constructor
49
We can create multiple packages inside our java project, we can also reuse it in other projects if we choose to do so.
true
50
Different ways to create object:
New Keyword New Instance Clone Method Deserialization By Factory method
51
If a class has multiple methods having same name but different in parameters, it is known as
Method Overloading.
52
When there is a chain of inheritance, it is known as
Multilevel Inheritance
53
- Refers to the class itself. - Enables you to access global variables inside the class if you have the same variable names in a parameter.
This Keyword
54
is a static variable within System that represents the output of your program (stdout).
out
55
New Keyword:
- 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
is a template, blueprint, or contract that defines what an object’s data fields and methods will be.
class
57
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.
Class
58
Are variables declared inside a method, condition, loops and any other block of code, it can only be accessible within that block of code.
Local Variables
59
is a technique of having more than one constructor with different parameter lists.
Constructor overloading
60
designed to perform initializing actions, such as initializing the data fields of objects.
constructors
61
has a unique identity, state, and behavior.
object
62
methods used to protect your data and make your code more secure.
Getters and Setters
63
Usage of Method Overriding
- 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
- A constructor which has a specific number of parameters - used to provide different values to distinct objects.
parameterized constructor
65
- 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.
Abstraction
66
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.
Object-Oriented Programming System(OOP)
67
A class in Java can contain:
- Fields - Methods - Constructors - Blocks - Nested class and interface
68
Types of Inheritance in Java:
Single Inheritance Multilevel Inheritance
69
It is a full Abstract Class that implemented in other classes.
Interfaces
70
acts as a non-access modifier in Java that is used mainly to manage memory.
Static Keyword
71
is a process in which a call to an overridden method is resolved at runtime rather than compile-time.
Runtime polymorphism
72
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().
Method
73
Advantage of Method:
- Code Reusability - Code Optimization
74
When type of the object is determined at compiled time compiler doesn’t decide the method to be called.
Static binding
75
is a group of similar types of classes, interfaces and sub- packages.
Java Package
76
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.
Constant
77
It is a rule to follow as you decide what to name your identifiers such as class, package, variable, constant, method, etc.
Java Naming Convention
78
If subclass (child class) has the same method as declared in the parent class, it is known as
method overriding