Skip to content

Latest commit

 

History

History

session-03-java-basics

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

Java language basics

Contents

Basic Syntax:

Explains the basic syntax of the Java programming language, including how to declare variables, use control structures, and perform input/output operations.

Data Types:

Explains the different data types in Java, including primitive types (such as int, double, and boolean) and non-primitive types (such as Strings).

Operators:

Explains the various operators in Java, including arithmetic, relational, and logical operators.

Control Structures:

Explains the different control structures in Java, including if-else statements, for loops, and while loops.

Arrays:

Covers arrays in Java, including how to declare, initialize, and manipulate arrays.

Methods:

Explains about methods in Java, including how to define, call, and pass parameters to methods.

Object-Oriented Programming:

Explains concepts of object-oriented programming, including classes, objects, inheritance, and polymorphism.

Assignment

Basic Syntax

Write a program that takes in two numbers from the user and prints out the sum, difference, product, and quotient of the numbers.

Data Types

Create a program that takes in a person's name, age, and salary, and prints out the person's name, age, and salary in the format "Name: [name], Age: [age], Salary: [salary]".

Operators

Write a program that takes in two numbers from the user and prints out the result of the following operations: addition, subtraction, multiplication, division, modulus, and increment/decrement

Control Structures

Write a program that takes in a number from the user, and prints out whether the number is positive, negative, or zero.

Arrays

Create a program that takes in a list of integers from the user and prints out the largest number in the list.

Methods

Create a program that takes in a string from the user and prints out the number of vowels in the string.

Object-Oriented Programming

Create a program that defines a class called "Rectangle" which has two properties: length and width. Write a method that calculates the area of the rectangle.

Create a class hierarchy for a simple simulation of a zoo. The base class should be "Animal", which includes common properties such as name, weight, and age. Create several subclasses for specific types of animals, such as "Lions", "Tigers", and "Bears", each of which inherits from the "Animals" class and adds its own unique properties and methods. Include polymorphism by creating a "feed" method for each animal subclass that behaves differently depending on the type of animal it is called on. Create enclosure classes that can "house" different types of animals. Implement an add method to add an animal to an enclosure. Have the enclosure check to make sure a herbivore and a carnivore animal aren't added to the same eclosure.

TODO: More assignments on inheritance and polymorphism