100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached 4.2 TrustPilot
logo-home
Summary

Summary Computer Science I (CSC1016S)

Rating
5,0
(3)
Sold
12
Pages
77
Uploaded on
02-11-2021
Written in
2021/2022

A comprehensive summary of the course notes for CSC1016S. The following sections of OOP Java are covered: Chapter One: Intro to Java Chapter Two: Input and Output Chapter Three: Flow of Control Chapter Four: Classes Chapter Five: Defining Classes Chapter Six: Arrays Chapter Seven: Inheritance Chapter Eight: Polymorphism Chapter Nine: Interfaces and Inner Classes Chapter Ten: Generics Chapter Eleven: Linked Lists

Show more Read less











Whoops! We can’t load your doc right now. Try again or contact support.

Document information

Summarized whole book?
No
Which chapters are summarized?
Chapter 1 to 13
Uploaded on
November 2, 2021
File latest updated on
November 6, 2021
Number of pages
77
Written in
2021/2022
Type
Summary

Content preview

Chapter One
Objects and Methods:
o Object-Oriented Programming (OOP): Programming methodology that views a
program as consisting of objects that interact with one another by means of actions
(called methods)
o Objects of the same kind are said to have the same type or be in the same class
o Other high-level languages have constructs:
• Procedures
• Methods (Java)
• Functions
• Subprograms etc.
o All programming constructs in Java, including methods, are a part of a class
Java Application Programs:
o Two common types of Java programs:
Applications
• A Java application program or “regular” Java program is a class with a method
named main
• When a Java program is run, the run-time system automatically invokes the
main method
• All Java application programs start with the main method
Applets
• A Java program that is meant to run from a Web browser
• Always use a windowing interface
• Can be run from a location on the internet or an applet viewer program
Computer Language Levels:
o High-level language: A language that people can read, write and understand
(A program written in a high-level language must be translated into a language that
can be understood by a computer before it can be run)
o Machine language: A language that a computer can understand
o Low-level language: Machine language or any language similar to machine language
o Compiler: A program that translates a high-level language program into an equivalent
low-level language program
(This translation process is called compiling)

,Byte-Code and Java Virtual Machine:
o Compilers for most programming languages translate high-level programs directly into
the machine language for a particular computer
o Since different computers have different machine languages, a different compiler is
needed for each one
o In contrast, the Java compiler translates Java programs into byte-code, a machine
language for a fictitious computer called the Java Virtual Machine
o Once compiled to byte-code, a Java program can be used on any computer, making it
portable
o Interpreter: Program that translates a program, written in Java byte-code, into the
machine language for a particular computer when a Java program is executed
o The interpreter translates and immediately executes each byte-code instruction
o Translating byte-code into machine code is relatively easy compared to the initial
compilation step
o Most Java programs run using a Just-In-Time (JIT) compiler which compiles a section of
byte-code, at a time, into machine code
Objects and Methods:
o Code: A program or a part of a program
o Source code: A program written in a high-level language such as Java, and the input to
the compiler program
o Object code: The translated low-level program and the output from the compiler
program (e.g. Java byte-code)
o In the case of Java byte-code, the object code is the input to the Java byte-code
interpreter
Class loader:
o Java programs are divided into smaller parts called classes
o Each class definition is in a separate file and compiled separately
o Class loader: A program that connects the byte-code of the classes needed to run a
Java program
o In other programming languages, the corresponding program is called a linker
Compiling a Java Program or Class:
o Each class definition must be in a file whose name is the same as the class name
followed by .java
o Each class is compiled with the command javac followed by the name of the file in
which the class resides
o This result is a byte-code program whose filename is the same as the class name
followed by .class

1.FirstProgram.java

2.javac FirstProgram.java

3.FirstProgram.class

,Running a Java Program:
o A Java program can be given the run command after all its classes have been compiled
o Only runs the class that contains the main method
(The system will automatically load and run the other classes, if any)
o The main method begins with the line:
public static void main(String[ ] args)
o Follow the run command by the name of the class only
Syntax and Semantics:
o Syntax: The arrangement of words and punctuations that are legal in a language
(grammar rules of a language)
o Semantics: The meaning of things written while following the syntax rules of a
language
Error Messages:
o Bug: A mistake in a program
o Debugging: The process of eliminating bugs
o Syntax error: A grammatical mistake in a program
(The compiler can detect these errors, and will output an error message saying what
and where it thinks the error is)
o Run-time error: An error that is not detected until a program is run
(The compiler cannot detect these errors - an error message is only generated after
execution)
o Logic error: A mistake in the underlying algorithm for a program
o (The compiler cannot detect these errors and no error message is generated)
System.out.println:
o Java programs work by having objects perform actions
o System.out: An object used for sending output to the screen
o The actions performed by an object are called methods
o println: The method or action that the System.out object performs
o Invoking/calling a method: When an object performs an action using a method
o Method invocation syntax (in order):
• An object
• A dot (period)
• Method name
• Pair of parentheses
o Arguments: Zero or more pieces of information needed by the method that are placed
inside the parentheses
Using = and +:
o The equal sign (=) is used as the assignment operator
e.g. answer = 2 + 2;

, o The plus sign (+) is used to denote addition or concatenation
(two strings can be connected together)
e.g. System.out.println("2 plus 2 is " + answer);
Identifiers:
o Identifier: The name of a variable or other item (class, method, object, etc.) defined in
a program
o Must not start with a digit
o All characters must be letters, digits, or the underscore symbol
o Theoretically can be of any length
o Java is a case-sensitive language:
Rate, rate, and RATE are the names of three different variables
o Keywords and Reserved words: Identifiers that have a predefined meaning in Java e.g.
public, class, void, static
o Predefined identifiers: Identifiers that are defined in libraries required by the Java
language standard e.g. System, String, println
Naming Conventions:
o Start the names of variables, classes, methods, and objects with a
lowercase/uppercase letter
o Indicate "word" boundaries with an uppercase letter
o Restrict the remaining characters to digits and lowercase letters
e.g. topSpeed, bankRatel, timeOfArrival, FirstProgram, MyClass
Variable declarations:
o Every variable in a Java program must be declared before it is used
o Tells the compiler what kind of data (type) will be stored in the variable
o Give the type of the variable followed by its name and a semicolon
o Variables are typically declared just before they are used or at the start of a block
(indicated by an opening bracket { )
o Basic types in Java are called primitive types:
e.g. int numberOfBeans;
double oneWeight, totalWeight;

Primitive types:
o Boolean
o Char
o Byte
o Short
o Int
o Long
o Float
o Double
R120,00
Get access to the full document:
Purchased by 12 students

100% satisfaction guarantee
Immediately available after payment
Both online and in PDF
No strings attached

Reviews from verified buyers

Showing all 3 reviews
4 year ago

4 year ago

3 year ago

5,0

3 reviews

5
3
4
0
3
0
2
0
1
0
Trustworthy reviews on Stuvia

All reviews are made by real Stuvia users after verified purchases.

Get to know the seller

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
stuviasisters University of Cape Town
View profile
Follow You need to be logged in order to follow users or courses
Sold
140
Member since
4 year
Number of followers
104
Documents
31
Last sold
4 weeks ago
stuviasisters

4,5

42 reviews

5
28
4
11
3
0
2
1
1
2

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their exams and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can immediately select a different document that better matches what you need.

Pay how you prefer, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card or EFT and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Frequently asked questions