Java Flashcards

1
Q

What are the four access modifiers in Java?

A

Private, protected, public and default (package).

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

What does the ‘private’ keyword do?

A

The private keyword is an access modifier, and variables, constructors or methods marked with the keyword ‘private’ can only be accessed by the code within the class.

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

What are can only variables, constructors methods be marked with the keyword ‘private’ and not classes?

A

This is because marking a class as private will mean that no other classes can access it, which fundamentally makes it useless in the overall program.

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

How can a privately declared variable or method be accessed by code outside of their declared class?

A

They can be accessed by using accessor methods, such as getters and setters.

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

How is the default access modifier declared and what does it allow for?

A

The default access modifier is declared by not declaring an access at all. This means that the variable, constructor, method or class can be accessed by code within the class itself as well as by the other classes in the package. Code outside of the package cannot access it.

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

What does the ‘protected’ keyword do?

A

The protected keyword is an access modifier that, just like the default access modifiers, allows code within the class and outside the class to access the protected variable or methods. Classes outside of the package to also have access. However this access is only available via child class.

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

What does the ‘public’ keyword do?

A

The public keyword allows for variables, methods and classes declared with the keyword be accessed by any class both inside and outside the package.

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

What is an Object?

A

Objects are instances of classes, and is an entity that has attributes, behaviour and identity.

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

What is a Class?

A

A class is a template that describes all the attributes of objects as well as the methods that implement the behaviour of member objects. It also serves as a template that describes the properties, state, and behaviours common to a particular group of objects.

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

What is multi-threading?

A

Multithreading is a type of execution model that allows multiple threads to exist within the context of a process such that they execute independently but share their process resources.

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

What are references?

A

References are addresses that indicate where an objects variable and methods are stored in memory.

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

What are the functions of JVM, and JRE?

A

The JVM provides a platform-independent runtime environment for Java Byte codes to be executed, whilst the JRE includes sets of files required by the JVM during runtime.

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

What is the difference between overloading and overriding?

A

When there are two methods of the same name but different properties, it is overloading. Overriding occurs when there are two methods of the same name and properties, and one is in the child class and the other is in the parent class.

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

What is the difference between equals() and ==?

A

Equals is a method used for checking the equality of two objects defined by business logic, whilst == is an operator used to compare primitives and objects.

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

What are contructors?

A

Constructors are blocks of code used to initialise an object.

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

What are the two types of constructors and what are they?

A

A default constructor is a constructor that has no parameter, and is always created if a constructor is not defined in a class. A parameterised constructor is a constructor that has known parameters.

17
Q

What is the JDK?

A

The JDK is the Java development kit and provides the tools and development environment need for creating java apps. it consists of things such as a compiler and JRE to allow for the the conversion of java into a byte code and code execution.