• Shuffle
    Toggle On
    Toggle Off
  • Alphabetize
    Toggle On
    Toggle Off
  • Front First
    Toggle On
    Toggle Off
  • Both Sides
    Toggle On
    Toggle Off
  • Read
    Toggle On
    Toggle Off
Reading...
Front

Card Range To Study

through

image

Play button

image

Play button

image

Progress

1/54

Click to flip

Use LEFT and RIGHT arrow keys to navigate between flashcards;

Use UP and DOWN arrow keys to flip the card;

H to show hint;

A reads text to speech;

54 Cards in this Set

  • Front
  • Back

STATIC modifier

Means that a member is associated with a class as a whole rather than just one instance; an individual object.

Why use the 'this' keyword?

To differentiate between a parameter and an attribute. I.e:




public void setSalary(int salary) {


this.salary = salary;


}

What do modifiers control?

-Visibility


-Mutability


-Association with class/object

Explain DEFAULT FIELD VALUES.

When an instance of an object is created, we must set that instance's field values to that of an attribute or another value; otherwise, the terminal will throw a nullpointException:main.

Explain MAINTAINABILITY

Any programmer must always be able to understand what the software is actually doing, so that they can easily make successful changes to the software. Maintainability is affected by readability, complexity and documentation.

Explain READABILITY

To make code have good readability, it is important to follow naming conventions, coding conventions and make the code neat, using automatic code from an IDE.

Explain COMPLEXITY

Code structure should be as simple and as logical as possible, but not necessarily the shortest it can be. Make a habit of using step-wise refinement wherein you break the code down into several simple steps to keep the flow of control as easy as possible.

Explain DRY PRINCIPLE

Don't repeat yourself; make sure to factor out shared code and use inheritance.

Explain DOCUMENTATION

The final product of a piece of code should include a user manual and a programmer guide; this can be constructed using comments to explain what the code is doing at a particular point.

Difference between VALIDATION & VERIFICATION

VALIDATION - does the product meet the requirements?


VERIFICATION - does the product work?

Explain MODEL

An abstract representation of something. It focuses on something's main features.

What does UML stand for?

UNIFIED MODELLING LANGUAGE


Explain ENCAPSULATION

The field values of an object cannot be directly seen by other classes, they can be accessed from the methods in the class that they are decalred; they control how field values are read and updated.

Explain GETTERS

A method in an class which returns the value held in a field.

Explain SETTERS

A method in a class which sets the content of a field to a certain value.

Benefits of GETTERS AND SETTERS

They provide standardised access to fields by other parts of your program and other programmers while using your code.

Explain PUBLIC MODIFIER

It means that the class, field,method or constructor can be accessed from anywhere.


NO restrictions.

Explain PRIVATE MODIFIER

It means that the class, field, method or constructor cannot be accessed from outside that class; field cannot be read or updated, method and constructor cannot be called.

Explain PROTECTED MODIFIER

It means that the class, field, method or constructor can only be accessed by the defining class, any class in the same package or any subclass of that class.

Explain FINAL MODIFIER

They are used to declare a field statement to be constant; a value that is declared public cannot be changed.

Difference between VARIABLES & FIELDS

FIELD - holds information relevant to objects of a specific class; defined in a class.


VARIABLE - holds temporary info to method execution; defined in a method.

Explain CONSTRUCTORS

It is like a special method that is executed whenever an instance, of the class it is defined in, is created. It will always initialise any new objects in the way you have specified within the constructor you are calling.

Explain METHOD OVERLOADING

When multiple methods are created which have the same identifier but different parameters.

Explain INTERFACES

They are contracts for how different parts of a piece of software may interact with one another. Each part can be implemented without knowing how other parts are implemented. An interface is a reference type in Java, it is similar to class, it is a collection of abstract methods. A class implements an interface, thereby inheriting the abstract methods of the interface.

What can an interface contain?

-constants


-method headers(name,parameters,return type)


-static methods

How to structure an interface?

public interface IPerson {


public void printDetails();


}

Can you have instances of an interface?

No, they merely describe the essentials of a class.

What modifier is given to any method and constant declared in an interface?

public, constants are declared as public, static and final.

How do you create an interface and call it within another class?

public interface Edible {


void.eat();


}




public static void myMethod(Edible e) {


e.eat();


}





Benefits of INTERFACES

Abstraction - can write code that uses objects without knowing exactly what class they belong to; just that they conform to some known interface. Easier to change one part of the program without changing others.


Can combing code with different people at different times.

How to call an interface when creating a class?

public class MyClass implements Interface1 {


}

Can you have multiple interfaces?

Yes

Disadvantages of INTERFACES

If two interfaces define a constant with the same identifier, there will be an error if you implement both and refer to the constant.


If two interfaces require the same method there isn't a problem, but if the only differ in return type then it is a problem.

Explain INHERITANCE

When information is common to several classes, we do not want to duplicate that information so we can have a subclass which inherits attributes and methods from another.

Explain SUBCLASS

The subclass is a class which inherits information from a superclass. I.e.


The subclass extends the superclass.


The subclass is a specialisation of the superclass.

Explain SUPERCLASS

The superclass passes down information to it's subclass(es). I.e.


The superclass is a generalisation of the subclass.

Can a subclass inherit from more than one superclass?

No

Does a subclass inherit from all it's ancestors?

Yes

When is the SUPER keyword used?

When calling upon a constructor which is in a superclass from the subclass; it allows for the subclass to do specific initialisation whereas the constructor in the super just initialises for info which may be common to a number of instances in it's subclasses.

Explain ABSTRACT

An abstract class cannot be instantiated; can be used as a place to define constants.

Can abstract methods provide implementation?

Yes

What must you do if you are extending an abstract class?

The programmer must implement all the methods declared in the abstract class.

Difference between ABSTRACT CLASS & INTERFACE

ABSTRACT CLASS - Can contain fields that are non-static and final, can contain implemented instance methods.


INTERFACE - Can contain static, final fields, method headers and static methods but can be implemented by multiple classes.

Explain OVERRIDING

The ability a subclass possesses wherein it can define it's own versions of methods inherited from a superclass; redefining the method is what is known as overriding. Parameters and return type must be the same, but implementation can be different.

Can the SUPER keyword refer to a subclass?

Yes, as long as it treats it like an instance of the superclass. I.e(Student extends Person):


This used in a student method means the current object is a student, but super used in a student method means current object is a person.

Difference between OVERRIDING & OVERLOADING

OVERLOADING - When multiple methods are defined in a class but with different parameters.


OVERRIDING - Redefining an inherited method in a subclass.

Explain FINAL

Final fields - cannot change their value.


Final classes - cannot be extended.


Final methods - cannot be overridden.

Explain BYTE

8 bit signed integer:


-128 to 127

Explain SHORT

16 bit signed integer:


-32768 to 32767

Explain CHAR

16 bit unsigned number:


0 to 65535

Explain INT

32 bit signed integer:


-2147483648 to 2147483647

Difference between DOUBLE & FLOAT

DOUBLE - 14 decimal places


FLOAT - 7 decimal places

Explain TYPE COERCION

Where java tries to make sense of incompatible types.

Explain pseudo-code

Informal high level description of the operating principle of the program.