LO1: Java Basics Flashcards
Natural Language vs Binary Code (machine language): Vocabulary, Syntax, Ambiguity
NL: Large vocabulary, complex syntax, semantic ambiguity.
ML: Small vocabulary (0s, 1s), simple syntax, no semantic ambiguity.
What is the process of programming? (from human to machine)
Human writes in a programming language which is passed through a compiler + interpreter to translate into machine language.
Programming languages have: vocabulary, syntax, ambiguity
Restricted vocabulary, small and restricted syntax, almost no ambiguity
What is a compiler?
Coverts Java code into byte-code which is a machine language for the Java Virtual Machine.
What is an interpreter?
Executes JVM, translates byte-code into machine language and executes. Translating is easier than compiling.
Source code has which file extension? After compiling into byte-code what is the file extension?
MyProg.java, MyProg.class
What is an algorithm?
Process of solving a problem using NL
What is pseudocode?
Algorthm expressed in formal language, no specific syntax.
What is a Program? (related to algorithm)
An algorithm expressed in programming language (specific syntax).
What are the 4 Golden Rules of Programming?
1) Understanding the problem. 2) Design a solution (algorithm). 3) Implement the solution (program). 4) Test the program/fix any issues.
What does a Java Program consist of? A Java program must always have which method?
Classes, methods, statements. Java program must always have main method.
What are the 3 types of errors? (describe them)
Compile-time errors (syntax): Compiler will find syntax errors, the executable is not created until these are fixed.
Run-time errors: A problem that occurs during program execution. Causes unexpected termination of program. (ex. divide by 0, infinite loop).
Logical errors: Error in algorithm, compiler cannot catch them, incorrect results.
What is the hardest error to detect?
Logic error since the IDE usually gives hints about the other ones.
When are compilation, run-time, and logical errors detected?
Compilation error: compilation phase.
Run-time and logical errors: Program execution.