Académique Documents
Professionnel Documents
Culture Documents
Java jargon
Variable scope
How do you put both files in the same package to call them?
What is a singleton?
and
understand
how
integrated.
In
it
is
important
both
general
to
aspects
terms,
are
back-end
and
retrieval,
servlets,
Web
database
principles,
applications, JDBC,
servlet
containers,
development
for
concerned
with
the
delivery
Web
browsers,
of HTML content
to
servlets
is
developers
will
work
to
visual
designs
using
combination
of
formats
Swing
applications
or
commonly
these
days)
Abstract
the
(less
where
statements
you
and
can
enter
execute
Java
them.
will
automatically
open
in
so-called
sandbox
direct
computer's
file
access
system
to
the
and
host
blocks
found
in
the
Java
cache
how
to
remove
the
problem.
To
applet, object {
margin: 0.5em;
padding: 0;
}
A: Thinking
Java jargon
This
approach
accelerates
if (a == 10) { }
returns
Q: How
Java?
A: Assuming
and
store
the
minimum
and
of
an
iterator
of DataPointobjects
over
that
have
set
an int
getValue() method.
This
example
The
a
initial
value
for
the
mean
variable
since
of
primitive
Bitwise
shift
10
Variable scope
message
is
misleading.
more
11
Q: How do you put both files in the same package to call them?
A: If two Java source files are located in
the same directory and neither explicitly
declare a package name, they are implicitly
in
the
same
default
package
are
and
no
required
package
by
adding
the
13
reverse
associated
of
with
separators.
the
the
The
Internet
project
package
domain
with
dot
names
are
all
in
the
for
same
default
simplicity.
has
astatic class
14
int
instanceAccess
hostInstance.instanceInt;
}
}
one
whose
to
progressive
mathematical
Recursive
interrogation
processing
methods
must
at
each
be
or
pass.
designed
15
Q: What is a singleton?
A: A singleton class
is one in which
default
constructor,
to
prevent
If
governing
the
singleton
access to
the
in
question
same
is
system
16
Quantity
design
a Money type,
you
pattern.
can
For
associate
A: A
one
of
several
alternate
17
constructor
and
may
therefore
be
should
not
have
any
modifier
encapsulates
in
a
a JPanelwith
for
each.
The
extension
of
all
SwingComponent functionality.
standard
The
18
that
any
special
behaviour
below
uses
to
re-process
input
and
use
19
can
make
spelling
checker
with
a LinkedList dictionary?
helpful.
The
original HTML
Tidy
and
the Code
StyleJTidy
to
take
This
is
look
at
an
open
configuration
notes
and
20
A: The
engine
available
from
the MKSearch
Web
pages,
multi-threading
A: It
several
very
21
designing
and
converting
fonts
such
Interface concepts
Interface use
What are the rules for passing subclasses for method arguments?
22
Marker interfaces
Interface constants
Interface concepts
different
behaviour
in
special
conforms
to
one
of
the
existing
23
that
implementations
particularly
the
to
require
interface
work
effectively,
old-style
Abstract
24
use
Interface
(GUI)
because
classes
Graphical
can
User
implement
can
easily
be
implemented
by
25
The
declaration
of
in
curly
braces.
the
follows,
The
close
opening
parenthesis
of
relationship
creates
between
the
an
26
are
type-compatible
with
their parents.
The use of interfaces in Java is partly a
design compromise to support a limited
form of multiple inheritance. Purely abstract
interfaces
enable
classes
to implement
from
them
example,
class
flexible
class
hierarchies,
to
may
which
change.
For
implement
27
wrapper
around
the
encapsulated Vector to
an ArrayList, LinkedList or
some
other
A: An interface
That
programmers
different
to
classes
flexibility
write
to
or
fulfil
enables
adapt
a
many
particular
interface.
28
A: The
classes
can
inherit
the
type
29
importing
writing
the
statements
relevant
that
classes
and
instantiate
the
declare
are
Application
implicitly
part
Programming
of
an
Interface.
A: An
Java
networking
package
enable
for
example.
Java
in
classes,
this
The
publicly
properties
collection
are
and
called
the java.netAPI.
30
generated
from
specially
formatted
Interface use
the
need
when
you
are
the
same
way.
Separate
this
31
head
it
an AbstractProcessable class.
with
That
should
An AbstractProcessable superclass
may
implement
and
provide
some
subclasses
concrete
to
methods
for
such
as
use,
of
classes
above
that
implement
32
used
in
most
areas
of
application
code
can
process
them
interchangably.
of
similar
subclasses,
to
avoid
33
A: Java
must
be
declared to
be
Primitive
types
Object
types
Including
built-in
API
classes
and
Interface
Types
types
declared
by
interfaces
and
This
is
an
example
of
34
Q: What are the rules for passing subclasses for method arguments?
an
interface
called Avian,
superclassFlyingBird that
implements Avian and
two
concrete
so
is
implicitly
an Avian type,
not,
it
only
implementsAvian.
full answer hidden, click for full
answers
Premium members click below for full answer
What are the rules for passing subclasses for
method arguments?
Q: Can
interfaces?
A: To
illustrate
multiple
inheritance,
We
might
interfaces: Mammal,
have
which
method suckleInfant(Mammal),
two
has
and Flyer,
35
valid
or
necessary
for
interface
methods
interfaces.
themselves
Nested
may
are
even
in
interfaces
be
36
proximity
also
implementation
helps
changes
ensure
to
either
that
are
mutually compatible.
A class defined
inside an
interface is
class.
is
an
inheritance
superclass-subclass;
inherits
all
the
relationship
like
the
sub-interface
constant
variables and
abstract methods defined in the superinterface and can add its own.
Since an interface may have a static class
defined within it, it is possible for a class in
a sub-interface to extend a class in a superinterface, but that is a different thing
entirely. In this case the extension of nested
classes
is
no
different
from
37
except
the
A: In
when
interface,
the
class
implements
relationship
cannot
an
be
reversed.
A: It
not
permitted
to
declare
an
This
is
Java
language
design
Some
regard
this
free
A: Yes,
write
class
that
implements
the
implements
...
}
In
this
respect
the
39
class
explicitly
definition
fulfils
with
an
interface
concrete
method
inherits
is
used
the
type
when
an
definition
but
this
an AreaInterface with
method getArea() and
case
shows
single
how
that
is
implemented
in ConcreteCircle, ConcreteSquareand Concr
eteRectangle classes.
public interface AreaInterface {
40
double getArea();
}
does
not
instantiate
the
can
implementation
only
of
provide
given
one
method
41
method
signatures
and
intended
A: In
interface
methods
must
be
concrete
method in
the
Marker interfaces
declare any
compatibility
with
certain
42
identifying
it
as
Java
type
that
methods.
Marker
interfaces
are
just
add
43
A: In
class
must
implement
serialize
an
instance
will
throw
a NotSerializableException. However, it is
the programmer's responsibility to ensure
that an instance can physically be serialized
and de-serialized in a meaningful way, so
that the object's original state can be fully
restored. That can be a complex task,
especially when a class has field types that
are
final
and
do
not
implement
hence
the
A: An
interface
something
that
typically
is
represents
Processable
in
An
example
would
be
44
Interface constants
as publicstatic variables
of
the
that
are
available
to
all
for
method
arguments,
for
example.
45
A: The
means
universal
and
they
must
have
un-changable
Interface
these
properties.
variables
are
implicitlypublic because
interfaces
intended
an
to
provide
are
Application
to
and
Java
programmers
implement
in
their
to
own
cannot
be
overridden.
They
are
46
a List type
assigned
afinal variable
in
and
assigned
to
Q: What
interface?
A: The
of
setting
constant
variable
is
A: Your
wrong
two
reasons.
Firstly,
the
47
// API declarations
}
String
EXAMPLE
Multiple inheritance
Extending classes
48
Overridden methods
What is overriding?
How can I get the superclass to call back to a method in the subclass?
49
object
oriented
approach
and
the
For
example,
add
simple
full
answer
hidden, click
for
complete answers
Premium members click below for full answer
Is
inheritance
applicable
for
beginners
in
programming?
A: There
it extends another
class,
or
an
classes
they implement an
declare
interface,
that
which
has
would
that
be
extends
type
of Vector and
behaves
specialised
wrapper
like
around
adds
to
manage
the
stack
51
be
cast
to
a Vector as
necessary.
full
answer
hidden, click
for
complete answers
Premium members click below for full answer
Can you show examples of Java inheritance?
A: Specialization
inheritance,
not
is
an
application
particular
of
form
of
can
only
apply
in
relationships.
For
example,
to
specify
subclasses,
the
methods
which
is
of
their
specification.
more
general
superclass,
that
is
specialization.
There are no Java keywords to declare
particular applications of inheritance in Java,
they
are
formed
by
combination
other
Java
devices
visibility
shapes the
inheritance
52
Q: What
is
the
difference
between
abstract
classes
and
inheritance?
A: Inheritance
object
is a design principle in
oriented
Inheritance
means
languages
that
like
Java.
classes acquire
consider
an
method moveForward().
two
both
interface
Here's
some
53
example
code
for
full
answer
hidden, click
for
complete answers
Premium members click below for full answer
How does inheritance avoid duplication?
A: Inheritance
is
properties
behaviour
and
concerned
that
with
a
the
class
types
it
acquires
by
fully
qualified
class
name
same
class
and
refer
to
them
class
package
combined
with
assignment
the
of
implicit
package
54
assignment
combined
with
Multiple inheritance
class
inherits
superclasses
methods
with
the
from
same
two
method
full
answer
hidden, click
for
complete answers
Premium members click below for full answer
Why doesn't Java support multiple inheritance?
ultimately
descended
whether
from
there
is
an
Application
Programming
the
too.
55
the
class
instance
in
cast
the
it
to
anObject as follows.
Object objectType = null;
try {
objectType = (Object) testInstance;
System.out.println("Instance successfully
cast to an Object.");
}
catch (ClassCastException cce) {
// Should never be thrown
System.err.println("Instance could not be
cast to an Object.");
}
56
used
in
applications,
slightly
but
is
larger,
broader
usually
used
example
below
implements
the
an
by
adapting
full
answer
hidden, click
for
complete answers
Premium members click below for full answer
Is
multiple
interface
inheritance
better
than
extending a class?
57
A: The
However,
if
you
use
object
Q: Can
we
achieve
multiple
inheritance
with
in
Java
using
Extending classes
58
full
answer
hidden, click
for
complete answers
Premium members click below for full answer
What's
the
difference
between
importing
and
extending a class?
implicitly
extends
the
When
you
descended
from
at
if
you
explicitly
extend
59
and
extended
however
you
choose.
Having said that, graphical user interface
classes can be quite complex and rely upon
specific method calls to maintain their
integrity.
Be
cautious
if
you
override
with
blocking
is
primarily
any
subclass
60
is
not
visible
to
the
Overridden methods
Q: What is overriding?
A: So long as a class and its methods are
not marked final, a subclass can declare a
method with the same signature as one in a
superclass and its own implementation. A
typical
example
toString() method,
is
which
is
the String
declared
in
object.
Any
other
its
object
own
may
method
61
an
object
reference.
In
If
the
return
type
of
the
Q: Why
superclass?
A: An
signature
through
its
public
A: The
implement
method, void
which
has
render(Object).
The
constructor
and
the System.outPrintStream to
uses
render
object,
the
the
that
takes
full
answer
hidden, click
for
complete answers
Premium members click below for full answer
Can you give an example application that shows
overriding?
A: To
being
overridden
in
on
subclass,
the
use
method
A: It
an
private
fields,
but
not
inherited
the
fields.
return
equivalent
arrays
of Method objects.
To obtain a list of all inherited fields or
methods, a program would need to get the
superclass of the object in question, store
the
return
value
for
full
answer
hidden, click
for
complete answers
Premium members click below for full answer
How can I find the inherited attributes of a class?
64
of
provides
the
an
subclass,
explicit
reference
to
the
the
subclass SpecialNotifier.
has
full
answer
hidden, click
for
complete answers
Premium members click below for full answer
Can you give an example call to an overridden
superclass method?
Q: How can I get the superclass to call back to a method in the subclass?
A: This type of call to a method in the
superclass chained to a call in the subclass
can be done if the superclass calls an
abstract method that is overridden in the
subclass, see the example below.
full
answer
hidden, click
for
complete answers
65
overrides
concrete
method.
guarantee
that
The
the
subclass
the
superclass
implied
override
and
write
an
appropriate
but
should
enforce
the
67
documents,
you
might
have
fulfil.
You
might
then
anAbstractDocument that
create
provides
declares
an
to
implement
their
would
own
only
version
of displayDocument(JPanel) to
fulfil
class
but
cannot
include
any
concrete methods.
In a real program it is not a question of
whether abstract classes or interfaces are
better, because both have features that are
useful. It is common to use a mixture of
interface and abstract classes to create a
flexible and efficient class hierarchy that
introduces concrete methods in layers. In
practical terms it is more a question of the
appropriate point in the hierarchy to define
68
empty
abstract
methods
and
methods,
combine
concrete
them
through
defined
by
an
interface
and
an
not
viable
69
can
be
used
by
one
or
more
of
abstract
methods
being
theAbstractShape class
has
Subclasses
inherit
and
must
70
you
must
fulfil
the
range
of
potential
71
// Empty
}
an
abstract
method,
the
through
without
numerous
abstract
any
concrete
implementation.
A common use of abstract methods is the
template
design
pattern,
where
the
72
the
standard
dot
notation,
e.g. AbstractExample.staticMethod().
follows
that
static
methods
must
It
be
concrete.
using
the
dot
notation.
The
73
Java
Language
Specification.
The
is
structured
concerned
collaboration
with
forming
of classes with
74
the
concrete
implementation
would
be
private
fields,
so
private
or
with
The
concrete
implementation
of
the
method
If
an
has protectedvisibility,
75
same
or public visibility.
If
an
abstract
concrete
implicitly
invokes
superclass
has
includes
inherited
includes
by
any
subclass.
an
getArea() method
It
also
abstract double
that
must
be
76
different
in
System.out.println("Static method
called.");
}
doSomething();
}
}
Since
abstract
classes
cannot
be
77
class
is
"abstract;
cannot
be
instantiated".
public AbstractConstructor() {
// Statements
}
// Statements
}
// Not permitted
// AbstractConstructor instance1 = new
AbstractConstructor();
78
Constructors
designed
in
only
abstract
to
be
classes
used
by
are
their
to
deliver
stock
template-like
public
class
ConcreteSubclassSuperconstructor extends
AbstractConstructor {
public
ConcreteSubclassSuperconstructor() {
super(INDEX);
}
}
79
What is a thread?
Why are wait(), notify() and notifyAll() methods defined in the Object class?
should
possibility
whether
in
it
be
designed
mind,
is
with
likely
with
this
judgement
and
what
its
should
normally
have
enough
context.
immediate
If
there
requirement,
is
avoid
the
no
thread-
Java
API
programming
is
used
purposes
for
that
general
cannot
be
classes
in
81
trade-off
against
the
time-
Java
programming
language
has
However,
multi-threaded
is
not
justified
for
most
simple
Q: What is a thread?
A: In Java the Thread class
represents a
The Threadclass
enables
Java
runtime
system
uses
fairly
82
to
thread
construct
creation
a
and
task
full
answer
hidden, click
for
complete answers
Premium members click below for full answer
What is a thread?
the
main
entry
point
thread
the
83
ready
states
before
the
Java
Virtual
Machine
with
in
which
themain() method.
to
execute
84
other
methods
for
configuration
and
manipulation.
only
has
one
reference
constructor
method
or
that
is
method,
signature.
passed
defined
to
in
a
the
A Runnable argument
executed
in
the
independent Thread,
is
normally
context
but
is
of
a
only
an
normal
85
full
answer
hidden, click
for
complete answers
Premium members click below for full answer
How does the run() method in Runnable work?
invokes
is
However,
it
passed
is
in
of
its
possible
to
is
more
common
to
implement
pass
it
to
to
inherit
application-specific
behaviour
useful
from
defines
an
However
of
actions,
for
example.
86
once.
A: There
required
to
override
compared
with
of
implementing
both
require
the
to
be
make
an
existing
class
hierarchy
also
from
avoids
thread
and
87
A: It
always
a Runnable type
best
rather
to
implement
than
extend
exceptional
circumstances
when
the
threaded
programs.
calls
to
its
constructor.
Subclasses
calling
88
new
executable
specialised.
Your
thread
and
threaded
is very
application
which
is
the
ultimate
inherit
be
called
by
thread
that
has
means
it
is
in
full
answer
hidden, click
for
complete answers
Premium members click below for full answer
Which class is the wait() method defined in?
89
the
method.
Secondly,
it
is
static
retains
the
Q: Why
defined
in
A: The
purpose
of
temporarily
pause
and
resume
the
90
The
act
of
waiting
is
associated
with
fundamentally
multi-threaded
be
waiting
for
the
same
object.
91
full
answer
hidden, click
for
complete answers
Premium members click below for full answer
Why are there separate wait() and sleep() methods?
Rather
than
return
92
These
measures
will
help
prevent
but
you
must
also
ensure
local
variables,
class
static
or
full
answer
hidden, click
for
complete answers
Premium members click below for full answer
Do I need to use synchronized on setValue(int)?
sub-class
that
declares
that
and
provide
This
a run() method
to
do
so.
very
minor
extensions
of
existing
93
full
answer
hidden, click
for
complete answers
Premium members click below for full answer
How do I create a Runnable with inheritance?
is
that
at
the
moment
of
to
those
code
blocks.
94
must
use
the
true
master
value.
effectively
disables
A: The
static
utility
method invokeLater(Runnable) is
intended
immediately.
The
runnable
deferred
effect
of
perhaps
before
to
the
restrict
other
runnable
thread
executes.
A: A synchronized method
uses what is
95
moment
and
execute
the
may
be
synchronized code.
Static synchronized methods
type Class as
the
context
for
the
to
be synchronized,
synchronized
instance
and
class
method
and
create
full
answer
hidden, click
for
complete answers
96
commonly
worker
thread
framework
97
to a mode of
any
concurrent
manages
internally
threads,
multi-threading
rather
than
the
JVM
behaviour
use
additional
systems
where
this
is
the
only
on
old
operating
systems
and
hardware platforms.
98
Central
Processing
Unit
(CPU)
without
spending
program
at
lots
of
time
the
expense
running
of
one
another.
faster
than
Java
green
thread
processing.
Java
Programming
1.5.
The
Interface
Java
Application
in
99
terminate
the
application. ThreadDeath is
a Throwable type, so the Apache logging
package may blindly catchThrowable rather
than
an Exception,
which
is
not
cleaned
up
before
logging
is
terminated.
Since this ThreadDeath instance is wrapped
in the commons LogConfigurationException,
the root cause of the problem is most likely
that a suitable LogFactory or Log instance
cannot be created by the corresponding
factory methods. In other words, your
logging configuration declares a type that
cannot be instantiated, possibly because of
bad spelling, ultimately because the named
class
is
not
available
to
the
relevant
classloader.
How can the JVM identify the main() method when its overloaded?
100
Application start up
line
declare
method
calledmain,
special
which
static
takes
any
arguments
passed
to
the
101
of
the
program.
It
class
instantiated.
that
It
hosts
the
method
is
the
102
designed
to
avoid
clashes
with
A: Java
103
Java
developers
a main() method
sometimes
to
run
simple
including
entry
point
with
signature
a
string
for
array
have
the
modifier, staticmethod
104
logic
and
indicates
is
the
associated
passes
the
to
an
Q: How can the JVM identify the main() method when its overloaded?
A: An overloaded main() method must
have
different
number
and
type
of
class
would
not
compile.
The
single
argument
which
is
of
below
is
overloaded
105
return
type
but
two
arguments.
The
configuration
values
for
the
A: The
loose.
The
main
method
takes
as String[].
The
name
of
the
also
accepted
by
the
compiler.
A: The static
main() method
takes
system
passes
an
array
that
contains
program
below
repeats
the
application's public
static
void
the
application
class
or
any
108
arguments
can
be
parsed
for
Q: Why
arguments?
A: When
you
invoke
the
Java
Virtual
class' main()method
receives
Q: How
order?
109
can
be
declared
final.
runtime
system.
it
will
throw
aNoSuchMethodError.
it
becomes
110
Exception
in
thread
"main"
java.lang.NoSuchMethodError: main.
If
you
restore
and
with
argument
in
the public
static
void
it
will
make
valid
by
the
operating
system's
111
the
asterisk
as
so
called
you
cannot
alter
the
fundamental
behaviour.
To
limit
argument
this
behaviour,
that
contains
enclose
an
asterisk
any
in
112
the
system
input
stream
in
Application start up
113
SimpleClass
SimpleClass();
instance
new
instance.doSomething();
}
}
114
MaxFactors.main(arguments);
Regular expressions
specialised
Application
class
is
class.
Programming
very
When
Interface
specialised,
its
an
(API)
internal
is
so
complex
that
of
lots
of
internal
code
that
such
as
the
representation,
locale-specific
Unicode
features,
but
the
that
could
stand
in
place
of
create
two
separate
the
fact
immutable
that
in
string
Java.
objects
Once
are
a
of
references
to
Java
string
117
variable.
quoted
However,
string
passing
argument
a
to
not
recommended
purposes.
for
general
create
an
independent
copy
of
an
does
have
"Efficient
System.out.println("Anonymous
instance.");
String
string
118
There
are
number
of
passed
to
119
a a1 = new a();
out.println("a");
will
the
string
literal
"a".
treat
it
as
a String object,
not
be
printed
its toString()method.
The
by
calling
default
will
output
coded
human
readable
diagnostic
information.
is
overridden
to
120
compare
that
character
content,
so
it
will
return false.
Always
use
the
primitive
value
string
121
A: This
amounts
of
text,
especially
in
122
extensive
loops.
each Stringconcatenation
For
statement
the
of
it. StringBuffer is
designed
generating
lots
of
additional
than
string
single
threaded
applications.
implementation
of
the
a StringBuffer in
terms
of
124
StringBuffer
buffer
StringBuffer(1024);
new
things
are
to
A: The
standard java.util.StringTokenizer class is a
special type of Enumeration that represents
segments
of
string,
which
may
be
125
A: The
Regular expressions
The
method
below uses the regular expression [^09]+ to check that none of the characters in
the input string is a number. The square
brackets define a character class. The
126
negation
modifier ^ followed
by
the
asks
the
regular
Static variables
area
where
static
context
is
127
necessary
is
during
program
start-up
be
kept
to
minimum.
Static
are
constants
value
to
another
type,
as
with
or
as
instance
of
type,
like
Static variables
A: A
static
variable
is
shared
by
all
it
directly.
Static
instances
are
full
answer
hidden, click
for
complete answers
Premium members click below for full answer
What is special about static variables?
To
reference
or instance variable
from
non-static
the
main
full
answer
hidden, click
for
complete answers
Premium members click below for full answer
I get "non-static variable this cannot be referenced
from a static context"!
129
method
in
separate
class.
Most
context.
For
example,
the
must
not
reference
any
instance
130
are
initialised
and
instance
and
can
methods
be
can
you
should
prefix
the
method
an
object
reference.
The
object
131
StaticMethodExample.staticMethod();
SuperConstructor
extends
public SuperConstructor() {
super();
}
132
object
new
A: Static
methods
cannot
truly
be
it
will
lead
to
confusing
reference
scheme
for
the
the
method
name
and
arguments, as below.
public class ExampleSubclass
ExampleSuperclass {
extends
as
superclass
version
133
becomes
apparent
when
an
extends
134
System.out.println("Calling static
method on superclass type...");
superStatic.testMethod();
}
}
The
subclass'
local
call
to
the
you
assign
an
instance
of
the
runtime
system
executes
associated
so
with
gives
as
aSuperStatic type,
so
executed
and
gives
thesuperclass message.
The Java compiler does not fail or warn
about static method name clashes, so it is
important to be aware of this scenario and
avoid it.
135
have
When
is
respectively.
This
helps
the
Language features
136
What is polymorphism?
Language features
137
138
139
141
142
Q: What is polymorphism?
143
144
145
Object concepts
Understanding constructors
What is a constructor?
146
Object design
Object methods
Object concepts
147
148
Understanding constructors
Q: What is a constructor?
A: A constructor is a special class method
that is used to create an instance of the
class. A constructor method is named after
the class it belongs to and may have
arguments. The constructor returns an
149
150
151
if the superclass does not have a visible noargument constructor, in which case you
must make the superclass constructor
visible or add call to an alternative
superclass constructor.
public class Example extends Superclass {
public Example() {
// Implicitly calls the superclass
constructor Superclass()
}
public Example(final int param) {
// Supersedes implicit call to superclass
constructor
super(param);
}
}
152
A: The
153
154
Object design
Object methods
156
void testOne() {
int test;
}
void testTwo() {
int test;
}
}
157
if ("thing one".equals(thing)) {
int a;
// Other statements
}
if ("thing two".equals(thing)) {
int a;
// Other statements
}
}
}
158
// Method statements
}
159
160
getDetails(File, String)
161
JDBC techniques
JDBC problems
SQL queries
162
163
164
165
166
167
168
169
170
JDBC techniques
171
JDBC problems
172
173
SQL queries
174
175
What is System.out?
176
Java exceptions
Class loading
What's the difference between the Class.forName() method and the new operator?
177
178
179
Q: What is System.out?
A: System.out is a static variable that
refers to the console output. The object type
ofSystem.out is PrintStream,
not PrintWriter, but it has similar
overloaded println methods. These print
180
181
182
Java exceptions
A: A NullPointerException is a runtime
exception that indicates the Java Virtual
Machine attempted to call a method on an
object, but the object reference was null.
This case may occur when a reference is
assigned from another method call that may
return a null value, such as
aHashtable look-up.
full answer hidden, click for
complete answers
Premium members click below for full answer
What is a NullPointerException in Java?
184
theSystem.getProperty(String) method.
The getProperty() method is expected to
return aString value for a given system
property, or null if the property does not
exist.
full answer hidden, click for
complete answers
Premium members click below for full answer
What's the best way to handle
a NullPointerException?
185
Class loading
186
187
188
189
190
191
String urlString =
"http://www.test.example/path/page.htm";
192
193
194
195
Storage structures
198
Storage structures
199
200
201
Compiler concepts
Compiler commands
How can I compile Java classes with packages on the command line?
Compiler diagnostics
202
Development environment
Compiler concepts
203
204
Compiler commands
205
206
Compiler diagnostics
207
c:\JavaSDK\bin\javac
c:\projects\java\MyClass.java
javac c:\projects\java\MyClass.java
208
209
210
Development environment
// OK
214
System.out.println(argument.toString());
// Also OK
try {
Object clone = argument.clone();
}
catch (CloneNotSupportedException cnse)
{
// Handle exception
}
}
215
216
217
218