DEV Community

Cover image for Java Basics
Karthick (k)
Karthick (k)

Posted on

Java Basics

Introduction to Programming Paradigms

1. Imperative Programming Paradigm

Imperative programming is one of the oldest programming paradigms and is closely related to machine architecture and Von Neumann architecture. It works by changing the program state through assignment statements and executes tasks step-by-step to achieve the desired result.

Examples of Imperative programming paradigms:

  • C: developed by Dennis Ritchie and Ken Thompson
  • Fortran: developed by John Backus for IBM
  • BASIC: developed by John G Kemeny and Thomas E Kurtz

2. Procedural programming paradigm:

This paradigm emphasizes on procedure in terms of under lying machine model. There is no difference in between procedural and imperative approach. It has the ability to reuse the code and it was a boon at that time when it was in use because of its reusability.

Examples of Procedural programming paradigm:


  • C: developed by Dennis Ritchie and Ken Thompson
  • C++: developed by Bjarne Stroustrup
  • Java: developed by James Gosling at Sun Microsystems
  • ColdFusion: developed by J J Allaire
  • Pascal: developed by Niklaus Wirth

2. Object-oriented programming: The program is written as a collection of classes and objects which are meant for communication. The smallest and basic entity is an object, and all kind of computation is performed on the objects only. More emphasis is on data rather than procedures. It can handle almost all kind of real-life problems which are today in scenario.

Examples of Object-Oriented programming paradigm:

  • Simula: first OOP language
  • Java: developed by James Gosling at Sun Microsystems
  • C++: developed by Bjarne Stroustrup
  • Objective-C: designed by Brad Cox
  • Visual Basic .NET: developed by Microsoft
  • Python: developed by Guido van Rossum
  • Ruby: developed by Yukihiro Matsumoto
  • Smalltalk: developed by Alan Kay, Dan Ingalls, and Adele Goldberg

2. Functional programming paradigms:

Functional programming is a paradigm based on mathematical functions where computation is performed through the execution of functions. It focuses on using functions for specific tasks while keeping data loosely coupled and minimising changes in program state. Some of the languages, like Perl and JavaScript, mostly use this paradigm.

Examples of Functional programming paradigm:

  • JavaScript: developed by Brendan Eich
  • Haskell: developed by Lennart Augustsson, Dave Barton
  • Scala: developed by Martin Odersky
  • Erlang: developed by Joe Armstrong, Robert Virding
  • Lisp: developed by John McCarthy
  • ML: developed by Robin Milner
  • Clojure: developed by Rich Hickey

Data Types

Java has 8 primitive data types to store different values.

  • byte: 1 byte, small integers (-128 to 127)

  • short: 2 bytes, integers

  • int: 4 bytes, integers (Most common)

  • long: 8 bytes, large integers

  • float: 4 bytes, decimals (needs 'f' suffix, e.g., 3.14f)

  • double: 8 bytes, decimals (Most common for fractions)

  • char: 2 bytes, single character (e.g., 'A')

  • boolean: 1 bit, true or false

Summary
We covered the fundamental building blocks of Java Data Types, Introduction to Programming Paradigms.

Top comments (0)