Section 1

Preview this deck

int data type

Front

Star 0%
Star 0%
Star 0%
Star 0%
Star 0%

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Active users

0

All-time users

0

Favorites

0

Last updated

6 years ago

Date created

Mar 1, 2020

Cards (98)

Section 1

(50 cards)

int data type

Front

width: 32 bits range: -2,147,483,648 to 2,147,483,647

Back

Java is interpreted

Front

You need an interpreter to run Java programs. Programs are compiled into Java Virtual Machine (JVM) code called byte-code. This byte-code is machine-independent and can run on any machine that has a java interpreter, part of the JVM

Back

public access specifier

Front

class members with this can be accessed anywhere in the same class, package in which the class is created, or package other than the one in which the class is declared

Back

How is Java robust

Front

Java compilers can detect many problems that would first show up in execution time in other languages Eliminates certain types of error-prone constructs in other languages Has a runtime exception-handling feature to provide programming support for robsustness

Back

How is Java architecture neutral?

Front

Write once, run anywhere With a JVM, you can write one program that will run on any platform

Back

Java Security levels

Front

Level 1: source code and java compiler then conversion to bytecode happens level 2: bytecode verifier level 3: class loader level 4: file system network access

Back

How is Java portable?

Front

b/c architecture neutral, they are portable and can be run on any platform w/o beign recompiled

Back

What is a method signature

Front

consists of: 1. method name 2. number of arguments 3. data type of arguments 4. order of arguments

Back

Variable types

Front

1. primitive or simple data types 2. abstract or derived data types

Back

protected access specifier

Front

accessible only to subclasses of the class in which they are declared

Back

class components

Front

1. data members (attributes) 2. methods

Back

boolean data type

Front

size: 1 bit range: true or false default val: false

Back

Bitwise x&y

Front

performs bit-wise AND operation. Evaluates to 1 if both bits x and y are 1. If either or both bits are 0, the result is 0.

Back

static methods

Front

Back

synchronized modifier

Front

controls access to a block of code in a multithreaded programming environment Java supports multithreaded programming and each thread defines a separate path of execution

Back

byte data type

Front

width: 8 bits range: -128 to 127

Back

Java architecture security featues

Front

1. compiler level security 2. byte-code verifier 3. class loader 4. sandbox model

Back

What gets passed by reference in Java?

Front

objects of abstract data type

Back

native modifier

Front

used only with methods inform compiler that the method has been coded in language other than Java indicates the method lies outside the Java Runtime Environment (JRE)

Back

public methods

Front

can be accessed from any object in a Java program

Back

How is Java dynamic?

Front

designed to adapt to evolving environment. New code can be loaded on fly w/o recompilation. New features can be incorporated transparently as needed.

Back

What exactly is a variable?

Front

name that refers to a memory location where some data value is stored. Each variable used in a program must be declared.

Back

Java is distributed

Front

Distributed computing involves several computers working together on network. Since networking is integrated into Java, writing network programs like sending/receiving data from a file is easy

Back

What is method overloading

Front

defining 2+ methods with same name but different signatures within a class.

Back

variable naming conventions

Front

1. unique 2. begin with letter, underscore, or dollar symbol followed by sequence of digits, dollar sign or underscore 3. NOT start with digit 4. NO embedded white space 5. NO keywords 6. case sensitive

Back

Java Object-oriented

Front

One of the main concerns in software dev is how to reuse code. Object Oriented programming provides great flexibility, modularity, clarity, and reusability through encapsulation, inheritance, and polymorphism Java was designed from its conception to be object-oriented

Back

modifiers

Front

static final abstract native synchronized

Back

2 ways of passing arguments in Java

Front

1. call-by-value: copy of the actual argument is passed to the formal arguments of the called method. Therefore the changes made to the formal parameters have no effect on the actual parameters. 2. call-by-reference: Passes the reference to the memory address and not the value of the actual parameters to the formal parameters in a method. Therefore, changes made to the formal parameters affect the actual parameters.

Back

character data type

Front

has width of 16 bits and set of standard ASCII characters ranging from 0-127

Back

When to use method overloading:

Front

when you have several methods performing closely related tasks a way of implementing polymorphism

Back

long data type

Front

width: 64 bits range: -9,223,372,036,854, 775, 808 to 9,223,372,036,854, 775, 807

Back

Types of Java apps

Front

1. Character User Interface (CUI) apps: access to system resources, can read/write to files on local computers 2. GUI apps used in windows environment 3. Applets = small executable programs that run on webpage and require java-enabled browser 4. Servlets = programs that extend functionality of web servers 5. packages: collection of classes that can be reused by apps and applets

Back

Bitwise x | y

Front

performs bit-wise OR. Evaluates to 0 if both bits, x and y, are 0. If either x or y are 1, evaluates to 1

Back

How is Java secure

Front

implements several security mechanisms to protect yoru system from harm caused by stray programs

Back

Double data type

Front

has range of 64 bits range: 1.7e-308 to 1.7e+308 default val: 0.0 size: 8 byte

Back

abstract modifier

Front

used to declare classes that define common properties and behavior of other classes used as a base class to derive specific classes of the same type.

Back

Features of Java

Front

1. simple 2. Object oriented 3. distributed 4. robust 5. secure 6. architecture-neutral 7. portable 8. good performance 9. multithreaded 10. dynamic

Back

short data type

Front

width: 16 bits range: -32768 to 32767

Back

Float datatype

Front

has range of 32 bit range: 3.4e-038 to 3.4e+038 default val: 0.0 size: 4 byte

Back

final modifier

Front

indicates that the data member cannot be modified does not allow the class to be inherited a final method cannot be modified in the subclass should be used to disable method overriding final class cannot be extended all methods and data members in a final class are implicitly final little to no performance benefit

Back

static modifier

Front

define variables/methods that belong to a class and not any particular instance of the class (can be used without object instances) used when a problem is best solved without objects used when objects of same type need to share fields associates method/variables with the class rather than an object of the class. Ask, "does it make sense to call this method, even if no object has been constructed yet?" If yes, it should be static.

Back

val >> val2 (right shift)

Front

shifts the bits of val1 to the right by the number of positions specified by val2

Back

x^y

Front

performs bitwise XOR operation. Evaluates to 1 if bits have different values and 0 if both bits have same value

Back

~x

Front

performs unary NOT operation. converts all 1s into 0s and all 0s into 1s

Back

friendly access specifier

Front

default if you don't specify any access specifier

Back

private access specifier

Front

accessible only by the class in which it is defined.

Back

val1 << val2 (left shift)

Front

shifts the bits of the val 1 operand to the left by the number of positions specified by val2

Back

How do the components of a Java system interact?

Front

1. apps written in Java language 2. Java compiler converts apps to Java bytecode 3. Java Bytecode executed on Java Platform 4. Software that provides you with a runnable Java platform is called a Java Runtime Environment or JRE 5. A compiler included in Java SE Development Kit or JDK converts Java source code to bytecode

Back

What is byte-code verification?

Front

1. in first phase, verifier checks for the structure of the .class file 2. second phase: bytecode is run. Verifier checks validity of classes, variables, and methods used in a program

Back

Multithreaded Java

Front

Multithreading smoothly integrated in Java, whereas in other languages, you must call procedures specific to OS to enable multithreading

Back

Section 2

(48 cards)

JSR-348

Front

introduces changes in areas of 1. transparency 2. participation 3. agility 4. governance

Back

instanceof operator

Front

test whether an object is an instance of specific class at runtime syntax: op1 instanceof op2 op1 is the name of an object and op2 is the name of a class. returns true if op1 object is an instance of op2 class

Back

When to use this

Front

when local and instance variables have the same name use in the constructor of a class to invoke another constructor of the class

Back

What class is always imported by default?

Front

java.lang.*

Back

What are interfaces?

Front

contain set of abstract methods and static data members. AKA a prototype for a class methods defined in an interface are only abstract methods

Back

final keyword

Front

used with variable, method or class, to prevent you from changing the value.

Back

JCP

Front

Java Community Process used to develop new Java standards. Benefits include: 1. free downlaods of all java specification requests or JSRs 2. early access to specifications 3. public review and feedback opportunities 4. open membership

Back

categories of built-in exceptions

Front

1. checked exceptions 2. unchecked exceptions

Back

Can you have a method in a subclass with the same name as a final method in the superclass?

Front

No. Generates compile time error

Back

method overriding

Front

creating a method in the subclass that has same return type and signature as a method defined in the super class. Created method of the subclass hides the method defined in the superclass enables you to create objects that respond to same method as defined in the superclass subclass MUST override abstract methods of a superclass cannot override static and final methods

Back

abstract method

Front

contains only declaration for a method w/o implementation details implementation of an abstract method is defined in the class implementing the interface

Back

multi-level inheritance

Front

inherits the properties of another subclass. e.g. if A is a superclass for B and B is a superclass for C. You can include any number of levels in multi-level inheritance

Back

try/catch syntax

Front

try { } catch (ExceptionName obj) { }

Back

define exception

Front

abnormal event that occurs during program execution and disrupts normal flow of instructions

Back

JVM

Front

ensures Java apps have the resources they need to run and perform in your environment. Runs java Bytecode Contained in the JRE

Back

OpenJDK

Front

open-source implementation of Java benefits include: 1. JDK reference implementation 2. new feature development 3. openness to community contributions

Back

Enums

Front

typesafe. can be statically imported can have fields, methods, and private constructors.

Back

Can a single try block have multiple catc statements?

Front

Yes. Necessary when try block has statements that raise different exception types

Back

catch block

Front

used as an exception handler. Enclose the code you want to monitor inside a try block to handle a runtime error

Back

Static variables

Front

1. can be accessed even if the class they are declared in hasn't been instantiated 2. called class variables 3. limited to a single copy per JVM 4. initialized when the containing class is first loaded 5. useful for containing shared data b/c static methods store data in static variables and all object instances share single copy of any static variabels

Back

What is the Unreachable code problem

Front

The Exception class is the superclass of all exception classes and catches different types. Java compiler gives an error stating that the subsequent catch blocks have not been reached. This is the unreachable code problem to avoid, the last catch block in multiple catch blocks must contain the Exception class object.

Back

INHERITANCE

Front

Back

EXCEPTION HANDLING

Front

Back

try block

Front

encloses statements that might raise an exception within it and defines the scope of the exception handlers associated with it

Back

super keyword

Front

enables subclass to refer to its superclass. Used to access: 1. superclass constructors 2. superclass methods and variables

Back

Considerations when using multiple catch statements

Front

1. multiple catch blocks generate unreachable code error 2. first catch block contains the exception class object, then subsequent catch blocks never executed 3.

Back

exaples of exceptions

Front

running out of memory resource allocation errors inability to find files problems in network connectivity

Back

final object reference

Front

prevent reference from pointing to another object. prevent assigning null to thereference

Back

when to use the "finally" clause

Front

finally block processes statements no matter whether an exception is raised or not.

Back

When is throws used

Front

used by a method to specify types of exceptions the method throws If method is capable of raising an exception it doesn't handle, it must specify that the exception has to be handled by the calling method. This is done using throws

Back

class loader

Front

responsible for correctly loading classes and connecting them with the core Java class libraries

Back

syntax to access member variable of a superclass is:

Front

super.<variable>

Back

Why use a static method?

Front

useful for APIs that are not object oriented. Java.lang.Math contains a lot of static methods commonly used in place of constructors to perform object initialization-related tasks cannot access non-static members of same class Cannot be overriden and don't allow any Virtual Method Invocation

Back

What is the JRE

Front

contains Java class libraries, Java class loader, and Java Virtual Machine

Back

When does Java use pass by reference?

Front

For Java objects, value of the right-side of an assignment is a reference to memory that stores a Java object. After assignment the values are equal because both sides refer to the same object. When you assign the value of x to y, you are not creating a new object, but a copy of the value of the reference.

Back

keyword this

Front

refers to the current object. Use this when a method defined in a Java class needs to refer to the object used to invoke that method.

Back

if no parameters passed to super() method?

Front

invokes default constructor of superclass

Back

categories of errors

Front

1. compile time errors 2. runtime errors

Back

Java benefits of final variables

Front

bug prevention since variable values cannot be modified once initialized thread safety: immutable nature of final variables eliminates concerns that come with concurrent access by mutliple threads

Back

high-order bit

Front

leftmost bit of the binary number

Back

Can top-level classes be static?

Front

no

Back

What is the throw statement

Front

causes termination of normal flow of control of java code. Stops execution of subsequent statements if an exception is thrown when the throw statement is executed transfers control to nearest catch block handling the type of exception the object throws

Back

JDK

Front

separate from JRE. What you need to compile Java source code.

Back

Syntax to invoke constructor of a superclass using super() method

Front

super(<parameter1>, <parameter2>);

Back

Throwable methods

Front

1. String getMessage() returns description of the exception 2. String toString() returns string object containing description of exception 3. Throwable fillInStackTrace() returns throwable object containing a stack trace 4. void printStackTrace() prints the stack trace

Back

Underscore rules

Front

1. can place them only between digits. 2. Cannot place them at the beginning or end of a number 3. cannot place them adjacent to a decimal/floating point literal 4. cannot place them prior to an F or L suffix 5. cannot place them in positions where a string of digits is expected

Back

single - level inheritance

Front

derives subclass from a single superclass. implemented with class B extends A

Back

val1 >>> val2 (unsigned shift)

Front

shifts bits of val1 operand to the right by number of positions specified by val2. A zero value is input in the high-order bit irrespective of the value of the high-order bit of val1.

Back