Java Programming - Software Application Development in Java SE - Standard Edition

TEAM

Java SE lectures are presented by Cristian Toma and Java SE team is (for the first series in DICE RO and the series in DICE EN, starting with year 2015 - alphabetically ordered by surname): Bogdan IANCU, Cristian TOMA, Claudiu VINTE, Alin ZAMFIROIU.

EXAMS & RE-EXAMS 2017

  • 29.05.2017, Room 2001 D, Year 3, RO + EN, 08.00 AM
  • 13.06.2017, Room 2001 A, 2001 D, 2017, Year 2 EN, 08.00 AM
  • 14.06.2017, Room 2001 A, 2001 D, 2017, Year 2 RO, 08.00 AM
  • 19.06.2017, Room 2001 A, 2001 D
  • 05.07.2017, Room 2001 A, 2001 D 

TESTS 2017

Test @ PC in week 8 or 9, on 24.04.2017:

Hour 08.00 am, room 2001 A and D, group 1039, 1041, 1042.

Hour 09.00 am, room 2001 A and D, group 1043, 1044 and 3rd year students RO.

Hour 10.00 am, room 2001 A and D, group 1051, 1053 and 1054 + 3rd year students EN.

Lectures & Labs

No. Download
Lecture
PDF
Lecture Description Download
Bundle
Lecture
Laboratory Description Download
Lab - Eclipse Project
- Java Programming administrative issues

General Recommandations:
- Download the bundle lecture archives, in order to run Samples in command line in Ubuntu 12 / 14 OS - native or in VMWare Player / Oracle VM VirtualBox.
General Recommandations:
- Download the bundle laboratories archives, in order to import and run Samples in Eclipse IDE under Ubuntu 12 / 14 OS - native or in VMWare Player
01. Java and JVM Overview, Java SE Synthax intro (if, switch, for, while), methods, Arrays, OOP intro and C++ analogy - will be reloaded in next lecture + Rasbian OS on a real RPi 3 board / macOS / Ubuntu Linux, the Java byte-code class running without any modification/re-compiling. The clone method necessity and implementation, "shallow" versus "deep" copy,, class and objects. 
02. Java OOP - Class, Objects + Immutable objects, Interface, Abstract Class, Inheritance, Polymorphism - late binding, "has a" versus "is a" relationship, Interface as Type ( declarative versus real type) analogy with C++ "pure" polymorphism, ClassCastException + Robocode Assignments. Java Inheritance, Polymorphism, Interface as type, Class cast exception.
03. Java Generics Programming and Datastructures/JCF - Java Collection Framework in analogy with C++ STL (Standard Template Library) in terms of: containers, iterators, and algorithms. Java Generics and Datastructures/JCF - Java Collection Framework with List<E> and Map<K,V> for interface as type.
04. Java I/O - Input / Output at byte and char level in stream oriented approach, File and RandomAccessFile classes. Java Native Interface - JNI (for understanding native methods) and Annotation plus Reflection (for understanding FTP server/automation of tests and XML parsing) will be a plus for understanding future topics. Java IO DataInputStream, DataOutputStream and RandomAccessFile sample.
05. Reload the previous lecture in terms of serialization, annotation + reflection, and JNI. Also as new topics the exceptions mechanism and two Source Code Design Patterns - Factory Methods and Singleton. Java Objects Graph serialization sample.
06. Java 8 Features and Functional Programming: Nashorn JavaScript Engine, Call-back and Inner Classes, Method references, default method, lambda expressions + functional interfaces, processing streams, Optional, Date/Time, and new API (Base64). Java 8 sample for testing the functional interfaces and lambda.
07. Multi-threading vs. multi-process, Multi-threading models, features, atomic operations, JVM and OS threads; Java API for multi-threading, Java Multi-threading issues – Singleton vs. Immutable Objects - Software Design Patterns impacted by Multithreading; Parallelism Q&A - sample for concurrent access and file parallel copying. Multi-threading for common concurrent resources access (Synchronized - build-in monitor objects).
08. Advanced Java Multi-threading (java.util.concurrent - ExecutorService + Future-Callable + Lock/Semaphore + Producer/Consumer) and Java 8 Lamdba expressions for multi-threading mechanisms. Standard Multi-Threading, Executor/Service and Future-Callable from java.util.concurrent for adding the elements of vectors/arrays in parallel. For parallel computing is recommended in Java Fork/Join mechanism available from JDK 7 and 8.
The didactic activity (lecture/laboratory/seminar 8/9) is dedicated for the test on PC; it could be in extra time
09. Java Networking Intro: TCP vs. UDP over IP with Java Socket programming. TCP case study with multi-threading for implementing FTP and HTTP protocol. UDP Socket Programming for uni-cast/multi-cast/broad-cast communications sample
10. Java NIO (New Input/Output) and RegEx (Regular Expressions) TCP Socket for implementing a trivial web/HTTP server sample with reg-ex parsing and NIO TCP Client
11. Java XML and JSON Java XML and JSON - Data Structures Encoding/Decoding Sample
12. JDBC and NoSQL Database Programming

Database Programming Sample for working with relational database (MySQL/SQLite) via JDBC and NoSQL database (MongoDB) via Java MongoDB library

13. GUI Intro (FX) and event handling Java FX + Multi-threading + socket including JAR development and call-back/lambda mechanism (loop for TCP socket in JAR project and another project with GUI updated from network messages).
14. The didactic activity (lecture/laboratory/seminar 14) is dedicated for the team projects presentations and/or discussions regarding Java presence into: SmartCards, Secure Elements, IoT - Internet of Things, Robotics (Pepper)/Drones (OpenCV), Embedded devices, Cloud & Web - JavaEE, etc.

 

E-Learning Solution

E-Learning solution platform for BSc. Economic Informatics study program @ Java Programming lecture, as part of the DICE/DEIC - Department of Economic Informatics and Cybernetics (www.dice.ase.ro) is based on SAKAI CLE, powered by Sakai Project and it is provided by ISM - IT&C Security Master program and ACS - Applied Computer Science And Cyber Security Team. Also for the blending learning process and the projects/tests upload, as alternative, http://online.ase.ro and Google Class-Room might be used.

The web address of SAKAI platform for the students from Economic Informatics master program is for the moment - the page SHOULD be accessed from Mozilla Firefox, Google Chrome, Opera or Internet Explorer browser, without any proxy set (e.g. without 'cache.ase.ro : 8080'), or alternatively, insert the exception for IP address 86.55.177.110 in proxy section + please accept SSL Warning because the security certificate is 'self signed' and you SHOULD choose the option link 'Proceed Anyway / Not Recommended':
https://86.55.177.110:8443/portal/

E-Framework Solutions

E-Framework solutions for Java Programming lectures and labs are based on VMWare client virtual machines, and they is provided by IT&C Security Master program - http://ism.ase.ro
The web address for download will be available for: 
- Linux Ubuntu 12 (VMWare Player) | Linux Ubuntu 14 LTS (Oracle VM Box): with JDK 6 | JDK 8 + Eclipse Indigo | Eclipse LUNA + GCC - Download U12 | Download U14

Evaluation & Gradebook Mark

The final exam mark is 60% (in examination session for the lecture), and the assesments/homeworks/reports/test&quizzes done by the student, during the semester are 40% (seminar/laboratory) from the evaluation mark. As milestone there is in week 8 a PC test in terms of Java SE written programs for a specific task and the (team) project in week 14.

For passing the discipline the student MUST obtain the final mark 5 out of 10. The following cummulative conditions MUST be achieved - MANDATORY:
- the examination mark within exam session must be at least 5 out of 10
- the test during the seminar is mandatory
- the project must be presented within laboratory classes / submitted to the theacher within the deadline
- at least 70+ % presences (for the gropus with 14 weeks: 11 seminars out of 14 / for the gropus with 11 weeks: 8 seminars out of 11) within the seminars / laboratories
- at least half of the lectures assignments must be submitted due the deadlines

All the content related with the tests, assesments and the final exam will be uploaded accordinglly with the established deadlines in the E-Learning System Solution based on SAKAI and provided by IT&C Security Master program - http://ism.ase.ro. The SAKAI e-Learning System Solution will be available soon, the username will be surname.firstname and the password has been communicated @ lecture 01.

Laboratory Test Evaluation Topics

  • Mark 5:
    • Development of Java projects - stand-alone and libraries (JAR) in command line with JDK (6 / 7 / 8) and IDE - Eclipse/IntelliJ IDEA/Netbeans
    • Java classes with minimum 3 fields according with the test requirements
    • Default constructor and constructors with parameters
    • Methods inhereted overriding from Object class: clone and equals
    • Accessor methods: get/set
    • Java arrays: uni-dimenssional and multidimenssional
    • Inheretance with polymorphism highlighting
    • Class relationships "has a" (composition) and "is a" (inheretance)
    • Debugging at runtime and objects memory layout understanding (deep-copy versus shallow-copy)
  • 1 point:
    • Java I/O Streams - byte and char oriented
    • Serialization and Deserialization mechanism
    • Exceptions handling with: try {...} catch() {...} and throws statements
    • Interfaces implementations and abstract classes approaches + immutable objects and Comparable interface (method compareTo) + hash method overriding
  • 1 point:
    • Java Generics & Reflection
    • Java Collection Framework: containers, iterators and algorithms - java.util.*
    • Software Design Patterns Intro: Singleton & Factory Methods
  • 1 point:
    • "Classic" Multi-threading for parallelism and concurrency (for the laboratory test WITHOUT java.util.concurrent - BUT included in the final examination)
  • 2 points:
    • Call-back mechanism / Advanced JVM feaures
    • Memory and algorithms optimizations
    • Original implementations of the test requirements

EXAM PC Development Test Evaluation

  • Mark 5 (All items are MANDATORY):
    • Development of Java projects - stand-alone and libraries (JAR) in command line with JDK (6 / 7 or 8) and IDE - Eclipse/Netbeans
    • Default constructor and constructors with parameters
    • Methods inhereted overriding from Object class: clone and equals
    • Accessor methods: get/set
    • Java arrays: uni-dimenssional and multidimenssional
    • Java classes with the composition ("has a") and inheritance ("is a") relationships plus polymorphism highlighting
    • Interfaces implementations and abstract classes approaches + immutable objects and Comparable interface (method compareTo) + hash method overriding
    • Java I/O Streams - byte and char oriented; Java NIO - optional
    • Serialization and Deserialization mechanism
    • Exceptions handling with: try {...} catch() {...} and throws statements
    • Java Generics & Reflection + Annotations (including Meta-annotations)
    • Java Collection Framework: containers, iterators and algorithms - java.util.*
    • "Classic" Multi-threading for parallelism and concurrency (for the the exam without java.util.concurrent - BUT included in the final examination for groups in A series - Executor/Services and Callable/Future mechanisms plus the Java 8 Fork-Join used in parallel computing - HPC = High Performance Computing)
    • Networking Programming (TCP, UDP and TCP with muti-threading) + Objects serialization/deserialization within the TCP/IP connections
    • Debugging at runtime and objects memory layout understanding (deep-copy versus shallow-copy)
  • 1 point:
    • Simple Software Design Patterns: Singleton & Factory Methods
    • Functional programming and Lambda Expressioons in Java 8 - optional
  • 1 point:
    • JDBC (Java Data-Base Connectivity) using SQLite / MySQL / Oracle
  • 1 point:
    • XML Parsing (using annotations within JAXB2 library) and JSON objects encoding/decoding (using third-party libraries such as JSON.org/Jackson)
  • 1 point:
    • GUI - Java Swing / Java FX 8 + call-back mechanism (JAR Library with loop for TCP Networking and another JAR library/Java project with GUI updating from the network requests/responses messages)
  • 1 point:
    • Advanced JVM features / Gradle, Maven, ANT for projects building automation - optional / Profiling & Test Intro (JUnit) - optional - NOT for 2014 & 2015
    • Memory and algorithms optimizations
    • Original implementations of the test requirements

Prerequisites

Fundamentals of C/C++, Linux/Windows OS and Networking.

Mission

Technological transfer from university to the students of practical and theoretical issues related with software applications development in Java SE

Java Programming - Software Applications Development Sections

1 – Java Language Fundamentals, JDK-JRE,
Object Oriented Programming (class, interface, inheritance, polymorphism, …)
2 – Java Generics, Annotations and Reflection (java.lang.annotation.* & java.lang.reflect.*)
3 – JCF – Java Collection Framework (java.util.*)
4 – Intro in Java Streams (java.io.*)
5 – Intro in Source Code Design Patterns (Factory Methods, Sigleton, Object Pool)
6 – Multithreading – concurrency / parallel computing
7 – Networking Intro – Java Socket (java.net.*)
8 – DB Programming Intro – JDBC – Java Data-Base Connectivity
9 – GUI – Graphical User Interface – Java Swing / AWT / Java FX2
10 – Structured Data Processing – XML/JSON Parsing – JAXB2

Java Topics Structure - for lectures and laboratories

  • Activity 01: JVM; JDK, JRE command line compiling and running + IDE (Eclipse/Netbeans/etc.) for debugging.
  • Activity 02: OOP - Object Oriented Programming Concepts: class, object, enum, interface, polimorphism (late binding => in Java all methods are virtual and all object are pointers – in C++ vs. JAVA) in Java Cloning and try-catch mechanisms in Java.
  • Activity 03: Java Generics, Java Addnotations and Reflection / Seminar – The structure of class file, Java Assembly and invoking annotated methods, plus the class field modification of a sample String operation JAVA class.
  • Activity 04: Java Collection Framework. Complete class sample with constructors, equals, hash, clone, compareTo methods that are MUST for working with various containers from JCF – List, Set, Map.
  • Activity 05: Byte/Char streams and input/output streams (I/O Stream); Building JARs libraries in command line / Seminar – Build application in JAVA for Input/Output-Streams and RandomAccessFile sample for invoices within a company + building JARs libraries from IDE – Eclipse/Netbeans.
  • Activity 06: Files and JNI – Java Native Interface (with DLLs/SOs) + Factory Classes and Methods, Singleton Classes and Objects Pool.
  • Activity 07: Java Sockets Intro for UDP programming – Unicast, Multicast, Broadcast simple sample.
  • Activity 08: Java Threads and Concurrent/Parallel programming – Sample of sharing the memory resources and critical regions guarded by mutexes with Java synchronized keyword.
  • Activity 09: Advanced Java Threads – Executor-Service and Callable-Future mechanisms and parallelism with Java Fork-Join / Producer and Consumer Sample - optional - applied within message of serialized objects consumption.
  • Activity 10: Intro to Java AWT and Swing programming for GUI development (including call-back mechanism) / Seminar – GUI for APPLET application 
  • Activity 11: Java FX2 (MVP - Model View Presenter design pattern architecture for RIA - Rich Interface Applications)
  • Activity 12: Java Sockets Intro for TCP programming in mono-thread and multi-thread mode. / Seminar – Simple proprietary TCP server that process due to a particular protocol messages.
  • Activity 13: JDBC – Java Database Connectivity Intro
  • Activity 14: Structured Data Processing - XML (JAXB2) and JSON (Jackson) Parsing

References

1. Bert Bates, Kathy Sierra, “Head First Java: Your Brain on Java - A Learner's Guide", Publisher O'Reilly Media, 1st edition (May 28, 2003) , ISBN-10: 0596004656, ISBN-13: 978-8173666650
2. Joshua Bloch, "Effective Java: Programming Language Guide", Publisher Addison-Wesley (June 15, 2001) , ISBN-10: 0201310058, ISBN-13: 978-0201310054
3. Elisabeth Freeman, Eric Freeman, Bert Bates, Kathy Sierra, Elisabeth Robson, "Head First Design Patterns", Publisher: O'Reilly Media; 1 edition (November 1, 2004), ISBN-10: 0596007124, ISBN-13: 978-0596007126
4. Bruce Eckel, “Thinking in Java", Publisher: Prentice Hall; 4 edition (February 20, 2006) , ISBN-10: 0131872486, ISBN-13: 978-0131872486
5. James Gosling, Bill Joy, Guy Steele, Gilad Bracha, Alex Buckley - "The Java Language Specification, Java SE 7 Edition": http://docs.oracle.com/javase/specs/jls/se7/jls7.pdf
6. Tim Lindholm, Frank Yellin, Gilad Bracha, Alex Buckley – “The Java Virtual Machine Specification, Java SE 7 Edition”: http://docs.oracle.com/javase/specs/jvms/se7/jvms7.pdf
7. Bill Venners, “Inside the Java 2 Virtual Machine", Publisher: McGraw-Hill Companies; 2nd edition (January 6, 2000), ISBN-10: 0071350934, ISBN-13: 978-0071350938
8. My Experience and lectures/labs slides presentations, examples, virtual machines + your visual, kinetic and auditory memory + SAKAI e-Learning System PROVIDED by ISM – IT&C Security Master Program - https://86.55.177.110:7443 + http://ism.ase.ro | http://acs.ase.ro
9. Web Resources & Tutorials:
http://java.sun.com
http://www.oracle.com/technetwork/java/index.html
http://www.oracle.com/technetwork/index.html
http://docs.oracle.com/javase/tutorial/
10. Java support archive

Assignments

The assignments are useful for practicing the Java lectures topics in developement and implementation for individual and team tasks.

Assignment 01.

Deadline - YYYY/MM/dd HH:mm: Current Year/03/18 23:50 GMT+2
Problem description: "Computing Taxes Problem - The US federal personal income tax is calculated based on the filing status and taxable income. There are four filing statuses: single filers, married filing jointly, married filing separately, and head of household. The tax rates for 2009 (2014?) are shown below:"

Upload and packiging: "The ZIP file has the source code files + *.sh/*.bat file for compiling and running the sample. The ZIP filename rule will have JavaSE_A01_SURNAME_FirstName1_FirstName2.zip". The upload is available through SAKAI, please see E-Learning Solution section from this page.
Objective: Implement using if-else and switch statements - please see Lecture 01 for start-up.
Copyright: Liang, Introduction to Java Programming, Eighth Edition, 2011 Pearson Education, Inc. All rights reserved. 0132130807: http://akyokus.com/courses/Fall2011/ise204/Lectures/Liang8e/03slide.ppt

Assignment 02.

Deadline - YYYY/MM/dd HH:mm: Current Year/03/18 23:50 GMT+2
Problem description: "Write a simple Java program that uses nested for loops to print a multiplication table – nested loops."
Upload and packiging: "The ZIP file has the source code files + *.sh/*.bat file for compiling and running the sample. The ZIP filename rule will have JavaSE_A02_SURNAME_FirstName1_FirstName2.zip". The upload is available through SAKAI, please see E-Learning Solution section from this page.
Objective: Implement using for and while statements - please see Lecture 01 for start-up.
Copyright: Liang, Introduction to Java Programming, Eighth Edition, 2011 Pearson Education, Inc. All rights reserved. 0132130807: http://akyokus.com/courses/Fall2011/ise204/Lectures/Liang8e/04lide.ppt

Assignment 03.

Deadline - YYYY/MM/dd HH:mm: Current Year/03/18 23:50 GMT+2
Problem description: "Declare one hundred numbers in a Java program, compute their average, and find out how many numbers are above the average."
Upload and packiging: "The ZIP file has the source code files + *.sh/*.bat file for compiling and running the sample. The ZIP filename rule will have JavaSE_A03_SURNAME_FirstName1_FirstName2.zip". The upload is available through SAKAI, please see E-Learning Solution section from this page.
Objective: Implement using Java methods, arrays, for and while statements - please see Lecture 01 for start-up.
Copyright: Liang, Introduction to Java Programming, Eighth Edition, 2011 Pearson Education, Inc. All rights reserved. 0132130807: http://akyokus.com/courses/Fall2011/ise204/Lectures/Liang8e/06slide.ppt

Assignment 04.

Deadline - YYYY/MM/dd HH:mm: Current Year/03/18 23:50 GMT+2
Problem description: "Develop in Java, 'Matrix' class and write a program that uses Matrix objects."
Upload and packiging: "The ZIP file has the source code files + *.sh/*.bat file for compiling and running the sample. The ZIP filename rule will have JavaSE_A04_SURNAME_FirstName1_FirstName2.zip". The upload is available through SAKAI, please see E-Learning Solution section from this page.
Objective: Implement OOP - Object Oriented Progrmming paradigms using Java class, interface, methods, arrays, for and while statements - please see Lecture 01 for start-up.

Assignment 05.

Deadline - YYYY/MM/dd HH:mm: Current Year/03/18 23:50 GMT+2
Problem description: Implement in Java Robocode (robocode-1.9.0.0), the following tasks:
5.1 Using just the ahead and turnRight/turnLeft methods create a robot that travels in a complete square once, beginning from its starting position. Make the robot travel 150 units for each side of the square.
5.2 Using a for loop create a robot that travels in a complete square 10 times.
5.3 Adapt the code so that it uses a loop that repeats four times to control the forward movement and turns.
5.4 Using a while loop create a robot that travels in a square forever (or until the round ends anyway).
5.5 Alter your robot so that it counts the number of squares it has travelled and writes this to the console.
5.6 Alter the above robot so that it incorporates an if statement such that it travels first clockwise and then anti-clockwise (hint: x % 2 == 0 for even numbers of x, and turnRight and turnLeft can accept negative degrees). Also have the robot print out whether it's currently travelling clockwise or anti-clockwise.
5.7 Create a new method called moveInSquare. The method should return void, and accept a single parameter, of type int called lengthOfSide. Alter the code from exercise 5.5 above so that the statements that describe how to move in a square are now in this method. Alter the run method so this method is called to make the robot move.
5.8 Experiment with adding additional attributes that control your robots behaviour:
a. a boolean attribute called aggressive can indicate whether the gun should fire at each corner
b. a boolean attribute called scanForRobots can control whether the robot rotates its radar at each corner
c. other attributes can control the size of the square, the number of degrees the gun and radar are turned, the direction of their turn, etc.
Also, create into the robot code with an 'onScannedRobot' method. Consult the documentation for the parameters and return types of the method. Implement the method to do something useful when it receives the event, e.g:
a) Write out the name of the robot you’ve seen, its current energy, and its distance
b) Fire on it!
Note: this extends the previous exercise so that its got all the other behaviour. It just adds this one extra event handler

Upload and packiging:
"The ZIP file has the source code files + *.sh/*.bat file for compiling and running the sample. The ZIP filename rule will have JavaSE_A04_SURNAME_FirstName1_FirstName2.zip". The upload is available through SAKAI, please see E-Learning Solution section from this page.
Objective: Implement if-else, switch, for and while statements inside a AI Game framework already developed by a third-party entity - please see Lecture 01 and 02 for start-up.
Hints: Download Robocode 1.9.0.0 from http://sourceforge.net/projects/robocode/files/latest/download?source=files. Be sure that you are testing the "game" using a network connection available. Please take a look into the following sections for hints.
- Unzip/extract the kit in /home/stud/javase/lectures
- Go to into the extracte directory and change permision for *.sh files from the directory of robocode (chmod 755 *.sh).
- Run (double click) on 'robocode.sh' file
- Click in main menu on 'Robot->Source editor' and create the source code of the robot ('File->New->Robot' - Package: eu.ase.jrobot) in order to implement the exercices.
- Implement the requirements in 'public void run()' method from the your class robot, which extends 'robocode.Robot' class.
- Compile the created source code ('Compiler->Compile').
- Start new battle from the main window of the Robocode ('Battle->New')

Assignment 06.

Deadline - YYYY/MM/dd HH:mm: Current Year/04/08 23:50 GMT+2
Problem description: Implement the following tasks using Java Multithreading API:
6.1 Parallel addition for two large vectors - benchmark with running time on various configurations (e.g. millis consumed in 8 threads on 2 cores, 4 threads on 4 cores, etc.)
6.2 Parallel dot product between two large vectors - benchmark
6.3 Parallel addition for two large matrixes - the two input matrix are read from file stream (text file) and the output is written also in file stream (text file) + benchmark
6.4 Parallel addition of the items from each row of a matrix object - benchmark
Upload and packiging: "The ZIP file has the source code files + *.sh/*.bat file for compiling and running the sample. The ZIP filename rule will have JavaSE_A06_SURNAME_FirstName1_FirstName2.zip". The upload is available through SAKAI, please see E-Learning Solution section from this page.
Objective: Use Java API multi-threading for concurrency and parallelism.


Resursele din aceasta pagina sunt puse la dispozitia studentilor care doresc sa acumuleze cunostinte suplimentare legate de programarea in limbajul Java sau care se pregatesc pentru certificare de tip SCJP.

Pentru o abordare structurata a volumului mare de cunostinte se pot folosi resursele:

Java Tutorial

Tutorialul Java 6 este structurat astfel incat sa acopere toate notiunile importante si sa ii permita unui programator sa invete elementele de sintaxa si conceptele limbajului Java.

1. Tutorial Java 6 – #1 Premise

Aceasta serie de tutoriale, care incepe cu acest post, are ca obiectiv sintetizarea elementelor limbajului Java 1.6 pentru invatarea programarii orientate obiect (POO) in limbajul Java 1.6 si evidentierea elementelor evaluate pri certificarea SCJP.

2. Tutorial Java 6 – #2 Concepte de baza

În acest post sunt prezentate regulile de bază, componentele şi structura programelor Java.

2.1 Tutorial Java 6 – #2.1 Cum sa definesti comentarii JavaDoc

In acest post sunt prezentate regulile de editare a comentariilor care sa permite generarea autoamata a documentatiei de tip JavaDoc.

2.2 Tutorial Java 6 – #2.2 Cum sa generezi JavaDoc in Eclipse sau NetBeans

In acest post sunt prezentate posibilitatile de generare autoamata a documentatiei de tip JavaDoc in Eclipse sau NetBeans.

3. Tutorial Java 6 – #3 Definire variabile de tip primitiv

In acest tutorial Java 6 vom vedea care sunt tipurile primitive de date, cum se definesc variabile, care sunt valorile implicite si ce nume putem da acestor variabile.

4. Tutorial Java 6 – #4 Vectori

In acest topic vom vedea cum definim si cum prelucram structuri de date de tip vector sau matrice in Java.

4.1 Tutorial Java – #4.1 Cum se adauga in Java un element nou la un vector existent

In acest post vedem care este solutia la problema adaugarii unui element nou la un vector existent.

4.2 Tutorial Java – #4.2 Cum se copiaza in Java elementele unui vector in alt vector

In acest post sunt descrise modalitatile prin care se poate copia un vector in alt vector, la nivel de valori.

4.3 Tutorial Java – #4.3 Matrice si masive multidimensionale (numai in Engleza pentru moment)

In acest post sunt descrise solutii de implementare in Java a structurilor de date de tip matrice si masive multidimensionale.

5. Tutorial Java 6 – #5 Structuri de control

In acest este descris cum se implementeaza in Java, structurile de control fundamentale:

  • structuri decizionale: if – then, if – then – else,switch
  • structuri de ciclare for, do-while,while – do, for imbunatatit (enhanced – for)
  • instructiuni de control: break, continue;

6. Tutorial Java 6 – #6 Clase si obiecte

Clasele reprezinta principiile de baza ale programarii orientate obiect. Clasele reprezinta notiuni abstracte, povesti, modele (blueprints), ce descriu:

  • caracteristicile, atributele unui obiect; reprezinta ceea ce stie sau ce este obiectul;
  • ce stie sa faca obiectul, comportamentul acestuia descris de metodele sale;

7. Tutorial Java – #7 Variabile de tip referinta (only in English)

8. Tutorial Java – #8 Stiva metodelor si memoria Heap

Pentru a avea o intelegere profunda a progamarii orientate obiect in Java sau in orice alt limbaj orientat obiect (cum ar fi C #),trebuie sa stii cum sunt gestionate lucurile intern de catre procesul Java si de JVM (Java Virtual Machine). Desigur, sintaxa si implementare principiilor POO (Programare Orientata Obiect) in Java sunt importante, dar vei avea o imagine mult mai clara cu privire la resursele necesare, memorie, performanta, transferul parametrilor, fire de executie si de eliberare a memoriei sau colectare a gunoiului (garbage collection), daca ai iti pui intrebari dincolo de Cum fac asta ? sau Cum scriu asta ?. Intrebari reale trebui sa fie Cum sau De ce se intampla asa ? (desigur, de la un punct, trebuie sa iei lucrurile asa cum sunt si sa mergi mai departe).

9. Tutorial Java – #9 Managementul memoriei, Garbage Collector si memory leaks

O problema importanta de performanta a fost si inca este, dimensiunea spatiului de memorie disponibil si modul de gestiune al acestuia. In ciuda faptului ca astazi tehnologia hardware ofera resurse mari de memorie virtuala, Random Access Memory, dezvoltatorii de software trebuie sa acorde atentie modului in care aplicatiile gestioneaza memoria, deoarece pot fi implementate solutii gresite, care vor bloca procesul sau sistemul de operare, deoarece nu mai este suficienta memorie virtuala.

10. Tutorial Java SCJP – #10 Domeniul de vizibilitate al variabilelor

Multe erori de compilare sunt generate de programatori deoarece nu au o imagine clara cu privire la domeniul de vizibilitate al variabilelor, cat sunt disponibile si când pot fi accesate. Conceptul de domeniu de vizibilitate descrie viata unei variabile, sau zona de disponibilitate, dupa ce aceasta a fost definita.

11. Tutorial SCJP Java – #11 Cum se utilizeaza String, StringBuilder si StringBuffer

In limbajele de programare, majoritatea tipurilor de date utilizate pentru variabile sunt valorile booleene, valorile numerice si sirurile de caractere (sau vectori de caractere terminati cu ‘\0’). In contrast cu C sau C++, in Java modul de gestiune a sirurilor de caractere este diferit, deoarece:

  • in Java fiecare char reprezinta o valoare Unicode pe 16 biti, si nu 1 octet;
  • in Java, valorile de tip siruri de caractere sunt gestionate de obiecte String;
  • in Java, sintaxa va permite sa utilizati String asemenea unui tip primitiv de date (puteti folosi operatorul = pentru a le initializa)
  • in Java, String sunt obiecte imuabile (immutable), in sensul ca odata ce sunt create, ele nu isi pot schimba valoarea.

12. Tutorial SCJP Java – #12 Immutable: String si Integer

Obiecte immutable (imuabile) sunt obiecte care nu isi pot schimba valoarea, odata ce acestea sunt create. Obiectul immutable cel mai cunoscut in Java este String. In afara de String, exista si alte obiect imuabile, iar unul dintre acestea este Integer (clasa si nu tipul primitiv), care are un comportament interesant pentru valori intre -128 si 127.

13. Tutorial Java SCJP – #13 Pachete si modificatori de acces pentru clase

Doua concepte importante ale Programarii Orientate Obiect impun separarea entitatilor (claselor) pe baza functionalitatii sau semnificatiei lor (modularizare) si ascunderea datelor si comportamentului în cadrul unei clase (încapsulare). Pentru a atinge aceste obiective se folosesc clase pentru a defini entitati care au atribute si un comportament (metodele lor). La un nivel superior, pentru o buna organizare a modulelor aplicatiei Java puteti utiliza pachete (packeges) pentru a separa modulele realizate de programatori diferiti sau pentru a grupa clasele în module in functie de utilitate, functie, logica.

14. Tutorial Java SCJP – #14 Methods and passing variables into methods (only in English)

14.1 Tutorial Java SCJP – #14.1 Ce inseamna sa ascunzi (shadow) o variabila
Conceptul de shadowing se produce atunci cand se defineste o metoda cu parametri de intrare care au nume identice cu variabile statice sau variabile de instanta (atribute).

14.2 Tutorial Java SCJP – # 14.2 Cum se definesc metode cu numar variabile de argumente – var-args
Incepand cu Java 5.0, puteti defini metode cu liste variabile de argument (var-args). Aceste metode pot fi utilizate in situatii cand nu este cunoscut numarul exact de argumente. Aceasta posibilitate este, de asemenea, disponibila si in alte limbaje de programare si chiar daca nu este folosit intensiv, este un subiect pentru examenul de SCJP.

15. Tutorial Java SCJP – #15 Clase wrapper pentru tipurile primitive

In Java exista 2 categorii importante de tipuri de date: referinte si primitive. De cele mai multe ori, valorile numerice, caracterele si valorile logice sunt utilizate ca primitive, deoarece sunt mai eficiente, ca viteza de procesare, sintaxa si efecte asupra memoriei. In ciuda acestui fapt, exista scenarii (cand folosesti Collections), cand este necesar sa stochezi valori primitive in interiorul unor obiecte. Pentru aceasta nevoie, Java ofera un set de clase folosite la ambalarea (wrap) valorilor primitive intr-un obiect.

16. Tutorial Java SCJP – #16 Constructori

Intr-o clasa se pot defini metode, dar exista un tip special de metode care sunt folosite pentru a rezolva o anumita problema, aceea de a construi obiecte. Constructori sunt metode speciale datorita rolului lor si pentru ca au o multime reguli privind declararea si utilizare.

17. Tutorial Java SCJP – #17 Modificatori de acces pentru metode si variable, atribute

Modificatorii de acces reprezinta modalitati prin care programatorul poate controla (acorda sau restrictioneaza) accesul la metodele si atributele definite intr-o clasa. Un motiv pentru a utiliza acesti modificatori de access este conceptul POO numit incapsulare, care cere ca atributele sa nu poata si accesate (citire/scriere) direct, ci doar prin metode accesor (cele prefixate cu get si set). Un alt motiv este necesitatea de a controla cum este folosita clasa si cum si ce valori ajung sa fie stocate in variabilele de instanta (atribute). De exemplu, daca se implementeaza clasa Persoana care defineste atributul varsta, nu este de dorit ca un alt programator sa poata initializa direct (cu orice valoare) acest atribut, deoarece poate folosi o valoare negativa.

18. Tutorial Java SCJP – # 18 Blocuri de initializare

Pentru a face prelucrari si pentru a obtine rezultate este nevoie de date. Si aceste valori de intrare sunt de obicei stocate in variabile statice, variabilele locale (definite în metode) sau variabile de instanta (variabile nonstatice definite în clase). Pentru a initializa o variabila o poti face la definitia sau mai tarziu intr-o metoda (constructor sau nu). In ciuda acestor doua solutii comune, exista o alta cale folosind blocuri de initializare.
Blocurile de initializarea sunt blocuri de cod definite intre { si }. Din acest punct de vedere, ele seamana cu blocuri/corpuri de metode, dar principala diferenta este ca blocurile de initializare nu au un nume. Ele sunt ca metodele, insa fara antet/header (tip returnat, nume metoda, lista de parametri).

19. Tutorial Java SCJP – # 19 Enumerari de tip enum

Incepand cu Java 5.0, framework-ul permite programatorilor sa defineasca un set predefinit de valori, o enumerare sau enum (cuvant cheie in Java). In plus, programatorii pot defini variabile care pot lua valori doar din enumerare, iar compilatorul va valida acest lucru prin generarea de erori in situatiile in care programatorul va incerca sa initializeze variabila cu o valoare din afara enumerarii. Enumerarile (enums) pot fi interpretate ca un nou tip de date, pentru care se defineste o restrictie cu privire la valorile sale.