CSCI21 Java fully solved
2025(graded A+)
Java Programming Language - answer - Object-oriented
programming language
- Platform independent
Java History - answer 1. 1991 - Sun Microsystems developed
language for consumer electronic devices
2. 1993 - WWW increased need for "dynamic" web pages
3. 1995 - Sun formally announces Java for Web use
Types of Java Programs - answer 1. Applications
- General-purpose programs
- Standalone
- Executed through OS
2. Applets (outdated and deprecated)
- Programs meant for WWW
- Embedded in Web page
- Normally executed through browser
Java Program Structure - answer 1. Java Program
- (optional) import declarations
- Class declaration
,2. Class
- Class name match file name
- May extend an existing class (e.g. Jcomponent)
- Contains fields and methods
Paradigm - answer - Collection of interacting objects
- Programs we specify are in these objects and how these objects
behave
Object - answer Something that has BAIT:
1. Behavior - methods (things that obj
2. Attributes - set of properties (field) w/ diff. values
3. Identity - distinct instance of a class of obj
4. Type - belongs to a class of similar objects
Object vs. Class - answer Object - instance of a class, physical entity
employee obj. = new employee();
Class - group of similar objects (blueprint of objects)
class employee { }
, EX. Class is bike, object is sports bike.
Constructor Method - answer - Special method that handles
initialization
- View as alternative to initializing fields as they are declared
Instances of Classes - answer - Single class can have multiple
instances
- Each instance is separate object that can have diff values for its
fields
- Definition of methods is same for all instances
- Only 1 class definition written as .java file for that class
What do you need to do to create Java classes? - answer Specify an
object's:
1. State: instance fields (data private to the object)
2. Behavior: methods (public interface of the class)
Instance Fields - answer - Variable - storage location that holds
value
- Variable declaration indicates variable's name (ex. balance) and
type (ex. double)
- Each object of a class holds a separate copy of instance field (ex.
diff bank accounts, diff balances)
Names (identifiers) in Java - answer - Identifier - name in program
2025(graded A+)
Java Programming Language - answer - Object-oriented
programming language
- Platform independent
Java History - answer 1. 1991 - Sun Microsystems developed
language for consumer electronic devices
2. 1993 - WWW increased need for "dynamic" web pages
3. 1995 - Sun formally announces Java for Web use
Types of Java Programs - answer 1. Applications
- General-purpose programs
- Standalone
- Executed through OS
2. Applets (outdated and deprecated)
- Programs meant for WWW
- Embedded in Web page
- Normally executed through browser
Java Program Structure - answer 1. Java Program
- (optional) import declarations
- Class declaration
,2. Class
- Class name match file name
- May extend an existing class (e.g. Jcomponent)
- Contains fields and methods
Paradigm - answer - Collection of interacting objects
- Programs we specify are in these objects and how these objects
behave
Object - answer Something that has BAIT:
1. Behavior - methods (things that obj
2. Attributes - set of properties (field) w/ diff. values
3. Identity - distinct instance of a class of obj
4. Type - belongs to a class of similar objects
Object vs. Class - answer Object - instance of a class, physical entity
employee obj. = new employee();
Class - group of similar objects (blueprint of objects)
class employee { }
, EX. Class is bike, object is sports bike.
Constructor Method - answer - Special method that handles
initialization
- View as alternative to initializing fields as they are declared
Instances of Classes - answer - Single class can have multiple
instances
- Each instance is separate object that can have diff values for its
fields
- Definition of methods is same for all instances
- Only 1 class definition written as .java file for that class
What do you need to do to create Java classes? - answer Specify an
object's:
1. State: instance fields (data private to the object)
2. Behavior: methods (public interface of the class)
Instance Fields - answer - Variable - storage location that holds
value
- Variable declaration indicates variable's name (ex. balance) and
type (ex. double)
- Each object of a class holds a separate copy of instance field (ex.
diff bank accounts, diff balances)
Names (identifiers) in Java - answer - Identifier - name in program