Java Tutorial Flashcards

summary

1
Q

What is JAVA ?

A

Java is a high level , popular, object oriented programming language , it’s purpose is : WORA (Write Once , Run Anywhere) , that means compiled java code can run in any plateform without the need to recompile it again

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Java Features

A
  • Object Oriented : Abstraction , encapsulation , polymorphism , inheritance , object,Class.
  • Platform Independant (interpreted also) : Java compiler compile code into byte code this byte code run by JVM on any platform.
  • Easy to learn / simple: if you understand OOP , and if you already know about c and c++ , java inherit features from these languages and remove its complex feature like pointers , operator overloading ,multiple inheritence and explicit memory allocation (provides garbage collection).
  • Secure : a developer is not required to interact with memory or operating system , Java provides automatic garbage collection so developer don t have to worry about memory leaks / management …
  • Architectural neutral : jre handles automatically java byte code execution on any processor
  • Portable : the same code executed on any platform
  • Robust : compile-time error check ,strict type checking and runtime error handling
  • Multithreading : multiprocess, thread handle , deadlock handle …
    it enables you to run multiple threads at the same time.
  • High performance : JIT(just in time) compiler improve performance
  • Distributed : developping internet based applications.
  • Dynamic : more dynamic than c and c++ because it can adapt to an evolving environment.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Java’s release date

A

1995

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Java’s original name

A

oak

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Java Platforms (editions)

A
  • JAVA SE ( java standard edition ) : develop and deploy portable code for desktop and server environments
  • JAVA EE ( java enterprise edition ) : to develop web apps
  • JAVA ME ( java micro edition ) : to develop mobile apps
  • JavaFx : to develop light-weighted user interface for rich internet apps.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

multitasking vs multiprocessing vs multithreading

A

multitasking : the ability of OS to execute multiple task simultaneously . there two type of multitask :
*multiprocessing : you can run multiple process and programs that doesn t share the same cpu and memory space (more isolated than threads) which make multiprocess a resource-intensive . it s good for CPU-BOUND where each process run in parallel on a different CPU cores.
*mutithreading : run mutliple thread with the same memory space and cpu (single process) which make communication / switch between threads more easier and lightweight.

=> Java have built-in support multihreading with Thread Class and Runnable Interface
BUT doesn t have built-in support multiprocessing , you can run java applications separately or use libraries for inter-process communication (IPS) if needed.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

C++ Features

A
  • middle level language : it can be used for systems development and large-scale app consumer.
  • Execution speed : C++ is a compiled language and use procedures extensively.Garbage collection and dynamic typing and other modern features impede program execution.
  • Object Oriented Programming : Growing code makes procedural code harder to handle. that’s the key advantage between c and C++.
    *Extensive Libraries : C++ has a vast libraries like 3rd party which make development faster
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Java vs C++

A
  • platform independent + interpreted + compiled :
    jAVA : can run on any platform (because java interpreted compiled)
    C++ : can t (only compiled)
  • Memory management :
    Java : GC manage it automatically
    C++ : manage it manually (with help of ‘new’ and ‘delete’).

*Libraries:
Java:don t support it directly, but we can configure it using 3rd party libraries.
C++:support direct system library calls.

*Multiple inheritance:
JAVA: support only single inheritance.
C++ : support multiple inheritance because of the ‘virtual’ keyword

*Mutithreading:
JAVA: support it.
C++:don t , but can by using 3rd party libraries.

*Pass by value/reference :
Java : Java support pass by value only , both in primitive type and also in object reference.

C++: support pass by value , and pass by reference using the pointer &.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

JVM Architecture

A
  • Class Loader:
    has 3 types : Bootstrap , Extension , Application Class Loader.
    JVM manages the process of loading,linking and initializing classes and interfaces in a dynamic manner.
    During the loading process, JVM find binary representation of a class and creates it.
    In the linking process, loaded classes combined with run-time state of JVM so they can be executed during initialiazing phase.
    During initializing, execution of linked classes
    _________________________________________
    JVM Memory/Runtime Data Areas:
  • Method Area:
  • JVM Language Stacks:
  • Native Method Stacks:
  • PC (Program counter) Register:
  • Heap:
    ___________________________________________
  • Execution Engine : comprises GC , Compiler JIT and Interpreter.
    =>JIT Compiler : is a part of JRE and it compiles byte code to machine code at runtime.
  • Native Method Interface :
  • Native Method Libraries : collection of c and c++ libraries which are essential for execution.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What JDK, JRE and JVM ?

A
  • JDK (java development kit) : it include all the tools ,executables and binaries for compile , debug and execute a java program.
    It is platform dependent (there are different installers for windows, mac, unix)
    JDK contains JRE and JVM.
    the version of JDK define Java version
    ______________________________
  • JRE (java runtime environment): it is JVM’s implementation , it is responsible for code execution
    platform dependent
    _____________________________
    *JVM (java virtual machine): it is a specification / something abstract.
    Convert byte code to machine code and can also run code.
    platform independent
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

How much variables java has ? and what is it ?

A
  • Local variables: are always inside a block ( constructor , method … ), created in block , destroyed after skip block.
    no default value.
    can t use access modifiers
    *static/class variables: outside block, inside class , have a default value
    can access without creating a new object (className.varName)
    created when program start , destroyed when program end
    there are only one class variable copy per class , regardless of how many objects we create from it.
    *Instance variables (non-static variables):outside block, inside class , have a default value.
    created when object created , destroyed when object destroyed
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

How much modifiers java has ? and what is it ?

A
  • Access Modifiers:
    -default : Visible to package , no modifiers required
    -public : visible to world
    -private : visible to class only
    -protected : visible to all subclasses and package
  • Non-access modifiers: final, abstract, strictfp
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Java Data types

A
  • Primitive:int, long , short, float , double , byte …
  • Object/Reference
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Java type casting (type conversion)

A
  • Widening: also implicit type casting where compiler automatically cast a smaller type to a larger type.
  • Narrowing: also explicit type where programmer manually cast type from large to small.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Java Generics

A

Are methods and classes that we use for different types without writing it again.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly