Discover millions of ebooks, audiobooks, and so much more with a free trial

From $11.99/month after trial. Cancel anytime.

Getting Skilled with Java: Learn Java Programming from Scratch with Realistic Applications and Problem Solving Programmes (English Edition)
Getting Skilled with Java: Learn Java Programming from Scratch with Realistic Applications and Problem Solving Programmes (English Edition)
Getting Skilled with Java: Learn Java Programming from Scratch with Realistic Applications and Problem Solving Programmes (English Edition)
Ebook503 pages5 hours

Getting Skilled with Java: Learn Java Programming from Scratch with Realistic Applications and Problem Solving Programmes (English Edition)

Rating: 0 out of 5 stars

()

Read preview

About this ebook

‘Get Skilled with Java’ teaches you to use Java programming ideas such as object-oriented and functional programming while building software programs in the Java language and the Java language itself.

This book covers all you need to know about Java programming right from the beginning to the intermediate level. The book demonstrates setting up the development environment and environment variables, installing JDK, writing programs utilizing Java's key capabilities, troubleshooting, deploying the applications, and bundling them. Each of the programming aspects has been explained in an easy-to-understand manner. At the end of each chapter, the book covers numerous programming exercises and tasks to improve coding and problem-solving capabilities.

After successful compilation, you will be able to construct Java programs for software development and utilize a variety of Java classes and libraries. You will also gain confidence in explaining Java's features and functionalities.
LanguageEnglish
Release dateJan 31, 2022
ISBN9789391392536
Getting Skilled with Java: Learn Java Programming from Scratch with Realistic Applications and Problem Solving Programmes (English Edition)

Related to Getting Skilled with Java

Related ebooks

Intelligence (AI) & Semantics For You

View More

Reviews for Getting Skilled with Java

Rating: 0 out of 5 stars
0 ratings

0 ratings0 reviews

What did you think?

Tap to rate

Review must be at least 10 words

    Book preview

    Getting Skilled with Java - M Rashid Raza

    CHAPTER 1

    Introduction to Java

    You have opted for one of the most prominent and advanced programming languages to get skilled in. Our curriculum is easy to understand and best for any beginner and developer to get expertise in Java programming. Let’s begin our journey towards Java.

    Every time when we heard about a new thing or term, the initial questions that comes in our mind are: What is this?, Why is this?, What people do with this? This is the nature of a human being and his/her curiosity to get to know about new things. People generally approach someone nearby to get to know more about new terms. Today, we live in the world of Internet. Hence, all our questions hit the search engine; either Google, Bing, or Yahoo.

    When we intend to learn something new, we have to start from its base and foundation. In this chapter, we will discuss the foundation of the computer programming language and how computer programming get enhanced day by day to fulfil the human needs. We will also discuss the foundation of Java language, how Java works, and what all we require to design, write, and run a Java program.

    Structure

    In this chapter, we will discuss the following topics:

    Java programming

    History of computer programming

    Why developers prefer to write in Java

    Software development kit (SDK)

    Java development kit (JDK)

    Java virtual machine (JVM)

    Objectives

    After successfully completion of this chapter, you will be able to:

    Discuss and explain the history of computer programming and the need for it

    Discuss the various computer programming languages

    Understand the Java programming language

    Understand why Java programming is widely used by programmers

    Explain the various types of programming languages and their uses

    Explain the software development kit and Java development kit

    Discuss the mechanism of compiler, interpreter, and execution of program

    Explain the architecture of Java foundation

    Introduction to Java

    Java is a high-level, object-oriented, functional programming language used to develop and design the computer- or mobile-based application and software. The pattern of Java programming is based on C++, which is also an object-oriented programming language. Java was developed by computer scientist James Gosling and his team in year 1991 in the Sun Microsystems lab.

    Types of programming languages

    There are two types of programming languages that we use to perform some operation on a computer and machine.

    Low-level language

    The low-level language is directly understood by the computer processor. We can only interact with hardware using binary numbers, 0 and 1 since machine and processor understand only the binary number and need all inputs only in the binary format to perform the operation. We have two types of low-level languages:

    The machine language: The machine language is made up of binary numbers, in which we have every command written in the binary format. This language is very fast since there is no interpreter required to convey the command to the processor. The processor can easily understand the steps written in binary. The machine language is also known as first generation language (1GL).

    The following is a machine language program sample to add two numbers variables. This program is just to show you how a machine code looks like. Don’t mess yourself into this:

    Example 1.1: A machine language program sample to add two numbers variables

    Assembly language: Assembly language is also a low-level language, but provides some ease to humans to write the program and understand what they will command to the processor to perform. Instead of binary numbers (that is, 0 or 1), we use the symbolic operation code to write the statement, that is, add, sub, mov.

    With the help of assembler, the assembly language program is compiled and converted into the machine language in string of 0 and 1 to get executed by processor. The assembly language is also known as second generation language (2GL).

    The following is an example of the assembly language program to add two numbers. This program is just to show you how an assembly program looks like. Don’t mess yourself into this:

    data segment

    a db 09h

    b db 02h

    c dw ?

    data ends

    code segment

    assume cs:code,ds:data

    start:

    mov ax,data

    mov ds,ax

    mov al,a

    mov bl,b

    add al,bl

    mov c,ax

    int 3

    code ends

    end start

    Example 1.2: An example of assembly language program to add two numbers

    The preceding program is just for your reference so that you can visualize how an assembly program looks like.

    High-level language

    The high-level language is also known as third generation language (3GL). The high-level language consists of the statement and syntax. These syntaxes are meaningful, and a person can easily learn and understand the programs. Execution of the program follows the order of the steps written in the program and executed one by one to reach the desired result.

    Java is an example of a high-level programming language. While writing a Java program, we keep the result in mind and then write the steps to get the desired result from that program just like an algorithm. C, C++, COBOL, and FORTAN are examples of high-level programming language (HLL).

    public class AddTwoNumbers {

    public static void main(String[] args) {

    int a = 5, b = 6, result;

    result = a + b;

    System.out.println(Addition of two numbers is: +result);

    }

    }

    Example 1.3: An example of a high-level program to add two numbers using Java

    The preceding program is written in Java to add two numbers and print the result as an output on the console. In the upcoming chapters, we will discuss every syntax of this programming one by one.

    History of computer programming

    The very first programming language was developed during the time of invention of computer by Ada Lovelace for Charles Babbage. After that, there is a huge list of programming languages developed by computer scientists and engineers for different purposes and needs. We will discuss few programming languages in this chapter, their invention, who invented and when:

    Algorithm for analytical engine: In the year 1883, a mathematician and colleague of Charles Babbage wrote an algorithm to compute the Bernoulli number (a sequence of rational number).

    Assembly language: In the year 1949, Kathleen Booth created a new language to interact with the computer. This is a low-level language to simplify the language of machine of code, so that a human would not struggle and mess with 0 and 1 to deal with computer. It was almost written as a machine code with operands and instructions, but in an understandable string.

    Autocode: The first Autocode and its compiler was developed by a British computer scientist Alick Edwards Glennie for Mark1 computer at University of Manchester. Autocode is the first programming language where compiler used to compile the program written in Autocode.

    Formula Translation (Fortran): In the year 1957, John Backus developed a language to simplify the computation of scientific, numerical, statistical, and mathematical calculations, which we called Fortran.

    COBOL: COBOL stands for common business-oriented language. In the year 1959, an American computer scientist Grace Brewster Murray Hopper developed this language for business use. The best part of this language is that the syntax that we write the program in is written in the English language. COBOL is still used in many domains, which we use in our daily life like mainframe, banking, traffic signaling, and so on.

    BASIC: In the year 1964, the mathematician John Kemeny and Thomas Kurtz developed a non-structured and general-purpose computer programming language to make the computer accessible for non-technical students as well. The motto of this development was to involve everyone towards the computer, even for those who did not know the technical and scientific things, because before this people had to write their own software or program to use the computer. BASIC stands for beginner's all-purpose symbolic instruction code.

    C: In the year 1972, an American computer scientist, Dennis Ritchie at Bell Labs developed C programming. This is based on BCPL (basic combined programming language). This is considered as a first high-level program language and widely used to interact with hardware. The C programming has been standardized by ANSI and ISO since 1989. This is being used for operating system applications, super computers, and embedded systems.

    C++: C was upgraded to C++ in 1985 by Bjarne Stroustrup. This is class-based, object-oriented, general-purpose programming language, and used in high-performance software and applications.

    Python: In the year 1991, Python was developed by Guido Van Rossum. Python is an object-oriented, easy, and efficient programming language for data science programs. Using Python, we must write very few lines of codes, to the point and only logical codes to get the expected result.

    Visual Basic: In the year 1991, this was developed by Microsoft corporation. This was the first programming language in computer history, in which the developer could reuse the existing module of code as a component. For that, visual basic provided a rich graphical user interface (GUI) to simply drag-and-drop the reusable components to add the functionality of that code in their new application and software.

    Java: In the year 1995, Java was developed by James Gosling in Sun Microsystems. Java is a class-based, object-oriented, functional programming, multi-purpose programming language. Java is well known for its best feature, which once complied, Java code can run on any operating system, which makes Java platform independent. The compiled code can run on any machine where JVM is installed. In September 2019, Java 13 has been released by Oracle.

    C# (C sharp): In the year 2001, C# was launched by Microsoft. C# is also an object-oriented programming language and is developed on the same pattern as Java and C++ are developed. This language is being used in almost all Microsoft products.

    GO: In the year 2009, Google developed this programming language by focusing of current programming world. A program written in Go is a fast, statically typed, compiled language that feels like a dynamically typed, interpreted language. The syntax used in Go is like C.

    Here, we have tried to list few of the most used programming languages by software developers. The list of programming languages is very long and ongoing. In this era of computer, every day we have a requirement, and to fulfil the requirement and gap, the computer scientists keep developing frameworks and languages.

    Features of Java

    Java has many unique features that are not available in other programming language. We will discuss the few outstanding features of Java that encourage developers to write their application and software using Java programming. Using Java, we can develop the complete application and software. Here are the features of Java programming language:

    Platform independent: Java is platform independent; it means we can build the code at once and then deploy and run in any machine or server.

    Scalability: Java is an object-oriented programming language, which makes the code modular, scalable, and easy to use and write.

    Library: Java has a very huge open-source library available in the market. Since it is open source and free program, anyone can contribute to create java library. These libraries later can be used by developers to write their code.

    Development for all device: It supports all kinds of development for all platforms. We can develop desktop, web, and mobile applications using Java.

    Open source JDK: Java is open source. A user can download the JDK from the official site and use it. A student or developer of Java need not pay anything to use Java. An individual developer or group of developers may contribute as well in JDK to build new classes and methods.

    Easy: Java is easy to learn and use. Many books and online materials are available to study Java language.

    Development tool: Some excellent IDEs are available for Java developers such as Eclipse, NetBeans, and IntelliJ. These tools have IntelliSense that keep providing hints to developers to complete the syntax and statement of code.

    These features of Java make it popular among the developers to get trained and encourage them to write their programs using Java.

    Software required to run Java

    Every software comes with a software development kit. That software development kit consists of all the required libraries and packages, which we need to write, and build the code written by developers. To start working with Java, we need the Java development Kit (JDK) to be installed in our machine. JDK is freely available and can be downloaded from Java’s official website. There are three modules of Java available in the market:

    J2EE: Java enterprise edition advance module of Java where we can use EJB, servlet, JNDI, and JMS. It also includes the J2SE. So, we can use the API and libraries of Java in our advance Java programming.

    J2SE: Java standard edition is SDK for core Java libraries and API that we mainly use to develop the application and program. This includes the API such as util and lang.

    J2ME: Java micro edition is the lightweight version of Java SDK. This is mainly used to develop the application and software for portable and small devices such as mobiles, tablets, and so on.

    These three modules are for different purposes. You may start with standard edition where almost everything is available for a Java developer.

    Java Development Kit

    JDK is a software development kit that provides the complete development environment to write and execute a Java program. Every programming language has its own software development kit. It creates the development environment in your machine and makes the required libraries available for you. You may refer the JDK official document to know all the out of the box available Java API specifications.

    JDK consists of JRE and JVM.

    Role of JDK:

    JDK compiles the Java source code (.java) into bytecode (.class). The type bytecode later can be executed on the JRE to run the software and application. After compilation, JDK creates .class file for every JAVA file with the same name. For example, the example.class file is the compiled version of the example.java source

    Enjoying the preview?
    Page 1 of 1