JAVA Introduction Flashcards
Lecture 1 oop
JVM Stands for
Java virtual machine
JRE Stands for
Java runtime environment
JDK Stands for
java development kit
JVM only understands ….
bytecode
java files are compiled into ….
bytecode
JRE provides the ….,….., and other components to run the applets
libraries and java virtual machine
true or false: JRE contains tools and utilities such as compilers and debugging applets and applications.
false
JDK contains …..
everything in jre plus tools and compilers and debuggers necessary for developing applets and applications
Properties of Java ? (7)
- Object oriented
- Interpreted
- portable
- secure and robust
- multi threaded
- garbage collector
- no support for multiple inheritance
java file is compiled to …
class file (bytecode)
memory in java is allocated (dynamically- manually - statically )
dynamically
deallocation is process of
removing the objects that are no longer referenced from memory
garbage collector helps prevent ….
memory leaks
object oriented programming is a ….
programming paradigm based on the concept of objects
each object contains data in form of ….
fields , methods
object constitutes the
building blocks of the program
true or false : classes can’t form a hierarchy
false , they can
Principles of object oriented programming
Encapsulation
abstraction
inheritance
polymorphism
encapsulation is
process of combining data and methods into a single unit called a class
encapsulation helps in
keep data both safe from outside interference
allows to expose only necessary data
encapsulation can be controlled via
access modifiers private public and protected
abstraction is
to hide complexity of the program by hiding the unnecessary detail from the user can be achieved by using classes
inheritance allows
creating hierarchy of related classes
allows code reusability
Polymorphism is
same concept can have different meaning in different contexts
polymorphism has two forms
overloading and overriding
overloading is
same method name with different parameters
overriding is
same name, same parameter , same return type but different body
branching forms
if-else and switch
loops comes in
for , while, do-while, foreach
loop control are
break
continue
for each is used to
traverse an array or a collection in java
True or false : for each loop has no loop variable
true
True or false: break and continue statement is limited to 1 per loop
true
T or F: arrays has a fixed size
true
if an array position is not initialized it is ….
NULL
an object is an … of a specific class
instance
t or f: objects reserves a place in memory
true
new is a keyword that
instantiate the object
if an object is not instantiated it is
null
to access fields we used … operator
dot operator
each class must have ….
at least one constructor
t or f: a constructor has a return value
false
constructor name must be …
the same as the class name
if no constructor is defined the complier creates one with no parameter called …
default constructor
default constructor intialize the values with … for numeric … for booleans …. for object references
zero, false, null
to call the parent class constructor we use
super();
UML is
unified modeling language object oriented modeling language
uml is represented by a ….. usually divided into three sections which are ….
- class name
- attributes (fields)
- operations (methods)
in uml + , - , # denotes ?
public , private, protected
relationship types in uml
are inheritance , and association
inheritance represents ….
a hierarchy between classes
association represents …
a relationships between objects
a package is a container …
for all related classes
access modifier none (Package local) is visible in ….
only within the same package
private is only accessible within …
the same class
protected can be accessed within…
the same package and subclass
public can be accessed …
anywhere
static modifier is
for the entire class and not for a specific object
final means its value
cant be changed
private is visible in the same package class?
no
private is visible inside the class
yes
private is visible inside the same package sub class?
no
protected is visible inside other package class?
no
protected is visible inside same package class?
yes
package local can be accessed from other package class
no
package local can be accessed from other package sub-class
no
protected modifier is visible in other package class
no
static modifier can be accessed via …
class name
non-static can only be accessed via …
object name
final must be initialized when …. or in …
declared, constructor