[go: up one dir, main page]

0% found this document useful (0 votes)
7 views4 pages

D.3 Revision Key Words

Uploaded by

concocalt
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views4 pages

D.3 Revision Key Words

Uploaded by

concocalt
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

D.

3 Revision Document:
Table of Contents:
D.3.1 Define the terms: class, identifier, primitive, instance variable,
parameter variable, local variable

D.3.2 Define the terms: method, accessor, mutator, constructor,


signature, return value

D.3.3 Define the terms: private, protected, public, extends, static

D.3.4 Describe the uses of primitive data types and the reference class
string.

D.3.5 Construct code to implement assessment statements

D.3.6 Construct code examples related to selection statements

D.3.7 Construct code examples related to repetition statements

D.3.8 Construct code examples related to static arrays

D.3.9 Discuss the features of modern programming languages that


enable internationalisation

D.3.10 Discuss the ethical and moral obligations of programmers.

Keywords:

-​ Class = is a template that contains methods and variables. Specific instances


can be made of the class.
-​ Identifier = name given to a package, class, interface, method, or variable.
-​ Primitive Data Type = The most basic data type that is predefined in a
programming ide, these include: Integer (a whole number), Floats (a decimal
number), Booleans(true or false), Characters(a single character: a, @, #),
Long(64-bit integer), Double (64-bit float),
-​ Instance Variable = when a number of objects are created from the same
class blueprint, they each have their own distinct copies of instance variables.
-​ Local Variable = a variable with a local scope e.g. variable in a method.
-​ Example Code:
public class Main {
public static void main(String[] args) {
method();
System.out.println(x);
// System.out.println(x); // This would cause an error, as x is not defined
outside main method
}

public void method() {


int x = 10; // x is a local variable}

-​ Method = a procedure related to an object.


-​ Accessor = returns encapsulated data in a class.
-​ Example Code:
public class Dog {
private String name;
private int age;

public Dog(String name, int age) {


this.name = name;
this.age = age;
}

// Accessor method for name


public String getName() {
return name;
}

// Accessor method for age


public int getAge() {
return age;
}

public static void main(String[] args) {


Dog myDog = new Dog("Buddy", 3);
System.out.println("Dog's name: " + myDog.getName()); // Output: Dog's
name: Buddy
System.out.println("Dog's age: " + myDog.getAge()); // Output: Dog's
age: 3
}
}

-​ Mutator = changes encapsulated data in a class.


Example Code:
public class Person {
private String name;
// Mutator method (setter)
public void setName(String newName) {
this.name = newName;
}

// Accessor method (getter)


public String getName() {
return name;
}
}

-​ Constructor = A method that creates and instance of a class.


-​ Example Code:

​ public class dog{


​ String name;

​ // constructor method
​ dog(String n){
​ name = n;
​ }
​ }
-​ Method signature = name and data requirement of a method (parametres).
-​ Example code:

​ public class dog{


​ String name;

​ // constructor method
​ dog(String n){ // this line is the signature of the method
​ name = n;
​ }
​ }

-​ Return Value = returned value from method.


-​ Private = method/field that can only be accessed within the class. Most
restrictive access level.
-​ Protected = method/field that can only be accessed within the package.
-​ Public = A class/ method that is declared public, can be accessed from any
other class
-​ Extends = used to denote inheritance to define a subclass when using JAVA.
-​ Static = a keyword that can be applied to a field, method, or inner class.
Static field, method, or class has a single instance for the whole class that
defines it, even without an instance of this class

You might also like