Prelims Flashcards
Who created JAVA and when?
James gosling et.al at sun microsystems, 1991
What was the initial name of java?
Oak, it was changed to java because there is already a programming lang named oak
The motivation for java is the need for platform independent language that could be embedded in various electronic products.
True
One of the first projects developed in java
A personal hand held remote control named star 7
The java technology is
- A programming language
- Deployment environment
- Application environment
- Development environment
As a programming language, Java can create all
kinds of applications that you could create using
any conventional programming language.
True
As a development environment, Java technology provides
you with a large suite of tools which are?
- Interpreter
- Compiler
- documentation generator
- class file packaging tool
Java technology applications are typically general-
purpose programs that run on any machine where
the Java runtime
environment (JRE) is installed.
True
Two main deployment environments
JRE supplied by java 2 software development kit, and on the web browser
contains the complete set
of class files for all the Java technology packages,
which includes basic language classes, GUI
component classes, and so on.JRE supplied by java 2 software development kit,
JRE supplied by java 2 software development kit
Code for printing output in Java
System.out.println(“ “);
Phases of java program
Editor - compiler - interpreter
(Write, compile, run)
Features of java
Java virtual machine ( JVM)
Garbage collection
Code security
An implementation - Its implementation is
known as JRE (Java Runtime Environment).
True
Whenever you write java
command on the command prompt to run the
java class, an instance of JVM is created.
True
Responsible for freeing any memory that could be freed. Happens automatically.
Garbage collection
It is attained in java through the implementation of the java runtime environment
Code security
Runs code for a JVM and performs class loading
Java runtime environment (JRE)
Responsible for loading all classes needed for java program.
Class loader
Adds security by separating namespaces for the classes of local file system
Class loader
Tests the format of the code fragments and checks the code fragments for illegal codes
Bytecode verifier
programming
style which is associated with the concepts like
class, object, Inheritance, Encapsulation,
Abstraction, Polymorphism.
Object oriented programming
Traditional procedural-oriented programming
languages (such as C, Fortran, Cobol and Pascal)
suffer some notable drawbacks in
creating reusable software components.
True
Functions are less reusable.
True
about writing procedures or methods
that perform operations on the data,
Procedural programming
about creating objects that contain both data and
methods.
Object oriented programming
Procedural programming has several advantages over object oriented programming
False
The problem solving phases
- Analysis
- General solution
- Verify
Procedural programming
Features
- top down design
- limited code reuse
- complex code
- global data focused
Object oriented programming features
- object focused
- code reuse
- complex design
- protected data
Advantages of OOP
- faster and easier to execute
- provides clear structure for programs
- helps keep the java code dry and easy to modify
What does DRY means
Don’t repeat yourself
What is the basic unit of OOP
Class
Two main aspects of object oriented programming
Classes and objects
like an object constructor,
or a “blueprint” for creating objects.
Class
The keyword for creating a new class
class
The keyword for creating a new object
new
To create a new object, you should:
specify the class name, followed by the object
name, and use the keyword new
With objects and classes, You can use the existing class created.
True
Creating objects with classes process
Declaration, instantiation, initialization
OP languages
permit higher level of
abstraction for solving
real-life problems.
True
An object oriented program consists of many well incapsulated objects
True
Benefits of OOP
Ease in software design, easy in maintenance, resuable software
a definition of objects of the same
kind. it is a blueprint, template, or prototype that
defines and describes the static attributes and dynamic
behaviors common to all objects of the same kind
Class
realization of a particular item of a class. In other words, an instance is an instantiation of a class
Instance
The term <blank> usually refers to <blank></blank></blank>
Instance
A Class is a 3-Compartment Box
Encapsulating Data and Operations
True
identifies the class.
Name
contains the static attributes of the class
Variables
contains the dynamic
behaviors of the class.
Methods
frequently instantiate
objects that use the objects of other classes
(and their data and methods). Sometimes
you write classes that do both.
Application classes
The principle used in creating private access is
sometimes called
Information hiding
_________ in Java is a mechanism to encapsulate a group of classes, sub
packages and interface
Package
What are the uses of package
- Preventing naming conflicts.
- Making searching/locating and usage of classes, interfaces,
enumerations and annotations easier - Providing controlled access: protected and default have package level
access control. - Packages can be considered as data encapsulation (or data-hiding).
Two categories of packages in JAVA
Built in packages (from java API)
And user defined packages
The library is divided into _______ and _________
Packages and classes
Syntax for importing a single class
import package.name.Class;
Syntax for importing a whole package
import package.name.*;
___________ is used to process the input and
produce the output.
Java (I/O) input and output
contains all the classes required for
input and output operations.
java.io package
Standard output stream
System.out
Standard input stream
System.in
Standard error stream
System.err
Java application uses an _________ to write data to a destination; it may be a file,
an array, peripheral device or socket.
Output stream
Java application uses an ___________ to read data from a source; it may be a file, an
array, peripheral device or socket.
Input stream
used to get user input,
and it is found in the java.util package.
Scanner class
These are notes
written to a code
for documentation
purposes.
Java comments
Three types of comments
Single line, multi line, documentation
tokens that represent names of variables,
methods, classes, etc
Java identifiers
Note: they are case sensitive and must begin with a $, and they are case sensitive.
predefined identifiers
reserved by Java for a
specific purpose.
Java keywords
Tokens that do not change and are constant.
Java Literals
Different types of Java literals:
- Boolean
- integer
- floating-point
- character
- string
It may come in different formats:
Decimal (base 8)
Hexadecimal (base 16)
Octal (base 8)
Integer literals
It represents decimals with fractional parts, and can be expressed in scientific notation
Floating-point literals
They have two values, true or false
Boolean
Represent single Unicode characters.
Character literal
Represent multiple characters and enclosed with quotation marks.
String literals
The java programming language defines eight primitive data types which include:
Boolean, char, byte, short, int, long, double, float
an item of data used to
store the state of objects.
Variable
A variable has a ________ and ________
Data type, name
indicates the type of
value that the variable can hold.
Data type
Declaring a variable syntax
<data> <name> [= initial value];
</name></data>
Two types of variables in java
Primitive and reference
Stores data in the actual memory location where the variable is
Primitive variable
Variables that store address in the memory location, points to another location
Reference variables
What are the different types of operators
Arithmetic, relational, logical, conditional
Compares two values and determines the relationship between the two values
Relational operators
They have one or two Boolean operands that yield a Boolean result.
Logical operators
A ternary operator that takes in three arguments
Conditional operator
The structure of an expression using a conditional operator
exp1?exp2:exp3
Evaluated from left to right
Compound condition
It is a sequence of data. Composed of bytes. Used by java to make I/O operation fast.
Stream