Java programming language
Introduction
✓ Static vs Dynamic
✓ Algorithm development
✓ Translating into program
✓ Testing and debugging
✓ Common java errors
✓ Assignment checklist
Notes taken by Udeshkumar
Tips for learning programming
● Do a little each day
● Don’t give up
● Take advantage of developer documentation
● Know how to ask for help effectively
● Code review
Static vs Dynamic
Static checking Checking for program bugs at compile time
Example - “5” * “7”
Java is a statically typed language
Dynamic checking Checking for program bugs at run time
Example - 5/0
Python is a dynamically typed language
More examples
Static checking
system.out.Println -- syntax error
Math.sine(2) -- syntax error
Arguments mismatch and return type error
Dynamic checking
out of range index
null object reference
Algorithm development
Informal instructions to write down as task description of problems. It imitates the structure
of programming language without the complete detail and syntax.
Image source: Hobart and William Smith
Translating into program
Image source: Hobart and William Smith
Testing and debugging
Program needs to be well-tested, the point of testing is to find and locate bugs.
Integrated Development Environment does this with the tools and options available for
a programming language.
It’s also good approach-Manual testing a piece of code before moving to automated
testing techniques. It can help you understanding problem in-depth.
One common error “Cannot find symbol”
Example:
int value = 56;
double deci = 5.7;
deci = 1.3;
System.out.println(dec);
Common java errors
Image source: Harvard
Assignment
1) Write a program that receives two names in arguments and alter the
names.
Compilation: javac Name.java
Execution: java Name “Kuma” “Ude”
Output:
Hello,good morning kuma and Ude
Hello,goodbye Ude and Kuma
2) Write a program to print the following output. Get input as an
arguments through console
Compilation: javac Welcome.java
Execution: java Welcome “Hello” “World”
Output:
Hello World Hello World
Hello World Hello World
Hello World Hello World
Hello WorldHello World
3) write a program that receives input arguments as three numbers
Rule: Perform Addition and Subtraction of 3 numbers. However, Multiplication,Division and
Modulus should compute only upto 2 numbers
Compilation: javac Arithmetic.java
Execution: java Arithmetic 8 4 2
Output:
8+4+2 = 14
8-4-2 = 2
8*4 = 32
8/4 = 2
8%4= 0
Note: / refers to the result obtained by dividing one number by other. % refers to
modulus operator to display the remaining values left in division of number.
Reference
https://docs.oracle.com/javase/tutorial/getStarted/application/index.html [ Main method in java]
https://docs.oracle.com/javase/tutorial/essential/environment/cmdLineArgs.html [ Echo program,
arguments through console ]
https://docs.oracle.com/javase/tutorial/ [ java basics]
https://docs.oracle.com/javase/8/docs/api/ [ API documentation ]
https://www.youtube.com/watch?v=ULEOb8wLa_k&ab_channel=IBMDeveloper [ Video session]
https://www.eclipse.org/community/eclipse_newsletter/2017/june/article1.php [ Articles, Sarika
Sinha]

javabasics_ programming development chapter01

  • 1.
    Java programming language Introduction ✓Static vs Dynamic ✓ Algorithm development ✓ Translating into program ✓ Testing and debugging ✓ Common java errors ✓ Assignment checklist Notes taken by Udeshkumar
  • 2.
    Tips for learningprogramming ● Do a little each day ● Don’t give up ● Take advantage of developer documentation ● Know how to ask for help effectively ● Code review
  • 3.
    Static vs Dynamic Staticchecking Checking for program bugs at compile time Example - “5” * “7” Java is a statically typed language Dynamic checking Checking for program bugs at run time Example - 5/0 Python is a dynamically typed language
  • 4.
    More examples Static checking system.out.Println-- syntax error Math.sine(2) -- syntax error Arguments mismatch and return type error Dynamic checking out of range index null object reference
  • 5.
    Algorithm development Informal instructionsto write down as task description of problems. It imitates the structure of programming language without the complete detail and syntax. Image source: Hobart and William Smith
  • 6.
    Translating into program Imagesource: Hobart and William Smith
  • 7.
    Testing and debugging Programneeds to be well-tested, the point of testing is to find and locate bugs. Integrated Development Environment does this with the tools and options available for a programming language. It’s also good approach-Manual testing a piece of code before moving to automated testing techniques. It can help you understanding problem in-depth. One common error “Cannot find symbol” Example: int value = 56; double deci = 5.7; deci = 1.3; System.out.println(dec);
  • 8.
    Common java errors Imagesource: Harvard
  • 9.
    Assignment 1) Write aprogram that receives two names in arguments and alter the names. Compilation: javac Name.java Execution: java Name “Kuma” “Ude” Output: Hello,good morning kuma and Ude Hello,goodbye Ude and Kuma
  • 10.
    2) Write aprogram to print the following output. Get input as an arguments through console Compilation: javac Welcome.java Execution: java Welcome “Hello” “World” Output: Hello World Hello World Hello World Hello World Hello World Hello World Hello WorldHello World
  • 11.
    3) write aprogram that receives input arguments as three numbers Rule: Perform Addition and Subtraction of 3 numbers. However, Multiplication,Division and Modulus should compute only upto 2 numbers Compilation: javac Arithmetic.java Execution: java Arithmetic 8 4 2 Output: 8+4+2 = 14 8-4-2 = 2 8*4 = 32 8/4 = 2 8%4= 0 Note: / refers to the result obtained by dividing one number by other. % refers to modulus operator to display the remaining values left in division of number.
  • 12.
    Reference https://docs.oracle.com/javase/tutorial/getStarted/application/index.html [ Mainmethod in java] https://docs.oracle.com/javase/tutorial/essential/environment/cmdLineArgs.html [ Echo program, arguments through console ] https://docs.oracle.com/javase/tutorial/ [ java basics] https://docs.oracle.com/javase/8/docs/api/ [ API documentation ] https://www.youtube.com/watch?v=ULEOb8wLa_k&ab_channel=IBMDeveloper [ Video session] https://www.eclipse.org/community/eclipse_newsletter/2017/june/article1.php [ Articles, Sarika Sinha]