Java Keywords: CSE 115 Spring 2006

You might also like

Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 15

Java Keywords

CSE 115
Spring 2006

Purpose
This set of slides contains a
running list of the keywords
that we have talked about so far
this semester and a brief
explanation of what each
keyword does.

class (added 1/30/06)


Indicates the start of the
definition of a class.

public class Name {


}

new (Added 1/30/06)


Indicates a call to a constructor
Used when you want to create a
new instance of an object
Use:
new constructorName();

package (Added 2/1/06)


Indicates membership for a
class in a particular package
Packages correspond to
directories on the file system
Use:
package nameOfPackage;

private (Added 2/3/06)


Access control modifier
(visibility)
Only accessible from within the
class

public (Added 2/3/06)


Access control modifier
(visibility)
Accessible from everywhere
and to everyone

void (Added 2/8/06)


Used as a return type for a
method.
Indicates that the method does
not return anything.
public void methodName() {
}

extends (Added 2/15/06)


Indicates that the class you are
writing has a superclass, which is an
indication of inheritance.
public class ClassName extends SuperClassName

this (Added 2/15/06)


Self-reference
Refers to the class itself
Can be used to have the class
call its own method
this.methodName();

return (Added 2/17/06)


Needed to indicate what value is
being returned from a method that
has a return type.
public NonVoidType methodName() {
//do some work
return someValue;
}

super (added 3/1/06)


Indicates a call to the superclass
method (either constructor or just a
regular method).

public ConstructorName() {
super(param);
}
public void OverriddenMethod() {
super.OverriddenMethod();

interface (added 3/3/06)


Indicates the beginning of an
interface definition.

public interface InterfaceName {

abstract (added 3/3/06)


Indicates that a method is
abstract (does not have a
method body).
public abstract void method();
OR
abstract public void method();

implements (added
3/3/06)
Indicates that the class you are
writing implements an interface.

public class Name implements InterfaceName{

You might also like