














Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
The key points in computer security which should be know as a beginner are given below:Oop Bootcamp, Object Oriented Programming, Programs, Collections of Classes, Each Class, Behaviour, Program, Invoking, Main Method, More Objects
Typology: Lecture notes
1 / 22
This page cannot be seen from the preview
Don't miss anything!















(^) Object Oriented Programming
(^) Write programs as collections of classes:
(^) Each class is a type. (^) Each class defines the behaviour of one or more objects of that class. (^) Java starts the program by invoking the main method of the “driver” class. (^) The driver's main method may then create other objects and execute other methods, and these methods may do the same, andsoforth ...
(^) Collection of data and methods.
(^) Instance of a class.
(^) Stored in memory, and only while program is running.
(^) Is a data value (just like 1 is an int).
Test anObject = new Test();
(^) Variables defined in class.
(^) Exist as part of object as long as object exists.
(^) Can be accessed using dot-notation within methods of
class (or outside class if public).
class Test {
int mark; String name, subject;
}
(^) Parameters send set of data values to method.
(^) Return values get one value back, like a function.
class Test { public void setName ( String aName ) { name = aName; } public String getName () { return name; } }
(^) this is a reference to the current object. (^) no need to define - automatic (^) toString is a special method that must return a String representation of the object. (^) define if needed – needed sometimes (^) equals is a special method that must return if an object is equal to the one passed in as a parameter. (^) define if needed – needed sometimes (^) Mutators (usually per instance variable) directly modify instance variables based on parameters. (^) define if needed – needed most of the time (^) Accessors (usually per instance variable) return the values of instance variables. (^) define if needed – needed most of the time
(^) Declare all instance variables as private so they
CANNOT be accessed using dot-notation except from methods in the same class.
(^) Declare some methods as public so they CAN be
accessed using dot-notation from methods in other classes.
(^) Variables/Methods that can be used without an object.
(^) Defined in class with “static” prefix.
(^) Instance variables are 1-per-object, static variables
are 1-per-class class Test { private static int counter; public static addOne () { counter++ } }
(^) Java stores objects indirectly by storing a their
memory locations – primitive data is stored directly.
(^) Assignment causes 2 variables to reference the same
object.
Test t1 = new Test ();
Test t2 = t1;
t1.setName (“hussein”);
System.out.println (t2.getName());
(^) Special value for any class type variable.
(^) Equivalent to zero or nothing.
(^) Used where variable does not reference anything
particular.
(^) Initialise an object to be a copy of another object,
passed in as a parameter.
(^) Results in a deep copy, instead of a shallow copy – a
completely new object, not just a reference.
public Test ( Test another ) { name = another.name; subject = another.subject; marks = another.marks; }
(^) Write a program to manage a bank account using a
BankAccount class.
(^) The BankAccount class should store information
about a single account (name, a/c number, balance).
(^) The driver class must interact with the user for typical
operations (withdraw, deposit, query, etc.).
(^) Write a program to manage the counting of votes in
an election.
(^) The Election class must have variables to count votes
for ANC/DA/Cope/ID/etc. and associated methods.
(^) The Vote class must store a single vote.
(^) The main method must create an Election object, then
create a sequence of Vote objects and send those to the Election object to be counted.
(^) Write a program that creates a family tree of Person
objects (defined/hard-coded in the driver class).
(^) Each Person object should store a reference to a
spouse and links to up to 3 children, with appropriate accessors and mutators.
(^) The tree should be printable using a single call to the
toString method of the head of the family tree.