Coder Social home page Coder Social logo

mbar0075 / java-tutorial-programs Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 5.06 MB

Various Different Java Programs constructed in practice for the Ordinary level and Advanced level examinations

License: MIT License

Java 88.35% HTML 2.63% JavaScript 1.80% CSS 7.22%
computer-basic data-structures-and-algorithms java learning object-oriented-programming principles-of-programming-languages

java-tutorial-programs's Introduction

Java-Tutorial-Programs

Author

Matthias Bartolo 0436103L

Preview:

import java.util.*;
public class BinarySearch
{
    public static void main( String args[]){
        Scanner sc = new Scanner(System.in);
        int num[]= {1, 2, 4, 8, 16, 32, 64, 128, 256};
        int size = num.length;

        System.out.println("Input number ");
        int input = sc.nextInt();
        int check = search(num,0,8,input);
        if(check==-1)
            System.out.println("Not found ");
        else
            System.out.println("found in location "+check);
    }

    public static int search(int[] a, int first, int last, int key)
    {
        int result = 0;

        if (first > last)
            result = -1;
        else
        {
            int mid = (first + last)/2;

            if (key == a[mid])
                result = mid;
            else if (key < a[mid])
                result = search(a, first, mid - 1, key);
            else if (key > a[mid])
                result = search(a, mid + 1, last, key);
        }
        return result;
    }

}

Description of Task:

This project involved a thorough investigation and practical application of diverse programming concepts, algorithms, and data structures. It aimed to enhance understanding and proficiency in fundamental programming principles. The tasks were completed using Java and were designed to provide practice and proficiency at both the Ordinary and Advanced levels examinations. The project focused on the following key areas:

1. Arrays: Understanding and manipulation of arrays, including indexing, element access, and array operations.
2. Searches: Implementation of search algorithms to efficiently locate specific elements within arrays or data structures.
3. Sorting: Application of sorting algorithms to arrange elements in a specific order, enhancing data organization and retrieval.
4. Classes and Objects: Utilization of object-oriented programming principles through the creation and utilization of classes and objects.
5. Instantiation: The process of creating instances (objects) of a class, allowing for multiple copies with their own unique characteristics.
6. Methods: Implementation of methods within classes to encapsulate reusable code and perform specific tasks.
7. Method Overloading: Defining multiple methods within a class with the same name but different parameters, providing versatility and flexibility in method usage.
8. Method Overriding: Redefining inherited methods from parent classes in child classes to modify their behavior.
9. Inheritance: Establishing relationships between classes to inherit properties and behaviors from a parent class to child classes.

public class Car extends Vehicle1
{
    private String fuel;

    public Car (Person theOwner, String brand, String mudel, String regno,String f_type) {
        super(theOwner,brand,mudel,regno);
        fuel=f_type;
    }

    public String toString(){
        return super.toString()+" \n"+fuel;
    }

    public void writeFuel(){
        System.out.println(fuel);
    }

    public void change_car_owner (Person owner){
        super.owner = this.owner;
    }
}

10. Polymorphism: Employing polymorphic behavior through method overriding and dynamic binding, enabling flexibility in method execution.
11. Abstract Classes: Defining abstract classes with abstract methods that require implementation in derived classes, enforcing common behavior among related classes.
12. Exception Handling: Implementing mechanisms to handle and manage exceptional situations or errors during program execution.
13. Constructor Overloading: Defining multiple constructors within a class with different parameters, facilitating the creation of objects with various initializations.
14. Creation of Administrative Systems: Developing administrative systems, such as Class Marks and Booking systems, to manage and organize data effectively.
15. Creation of Games: Designing and implementing games, such as Hangman, to engage users and provide interactive experiences.
16. ArrayLists: Utilizing ArrayLists, a dynamic data structure, to store and manipulate collections of objects efficiently.

import java.util.ArrayList;

public class Beatles
{
   //-----------------------------------------------------------------
   //  Stores and modifies a list of band members.
   //-----------------------------------------------------------------
   public static void main (String[] args)
   {
      ArrayList band = new ArrayList();

      band.add ("Paul");
      band.add ("Pete");
      band.add ("John");
      band.add ("George");

      System.out.println (band);

      int location = band.indexOf ("Pete");
      band.remove (location);

      System.out.println (band);
      System.out.println ("At index 1: " + band.get(1));

      band.add (2, "Ringo");

      System.out.println (band);
      System.out.println ("Size of the band: " + band.size());
   }
}

Special recognition and appreciation are extended to Mr. Raymond Cuschieri for his invaluable guidance, support, and dedication in imparting these fundamental programming principles and fostering the growth of programming skills. The knowledge and skills gained from this project have laid a strong foundation for further learning and application in practical programming scenarios.

Deliverables:

The repository includes:
Various Different Java Tutorial Programs constructed in practice for the Ordinary and Advanced level examinations.

java-tutorial-programs's People

Contributors

mbar0075 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.