Recent Posts

Friday, November 9, 2018

CBSE Class 11 Informatics Practices Chapter 2 Introduction to Programming Languages Part 1

Class Notes of Chapter 2: Introduction to Programming Languages
Part 1
Class 11th Informatics Practices

Introduction to Programming Languages



      Topics:

  • Introduction
  • Programming Fundamentals

  1. Token 
  2. Keywords
  3. Literal
  4. Identifiers
  5. Java Operators
  6. The Arithmetic Operators
  7. The Relational Operators
  8. The Logical Operators
  9. The Assignment Operators
  10. Misc Operators



            Introduction

            Java programming dialect was initially created by Sun Microsystems which was started by James Gosling and discharged in 1995 as the center part of Sun Microsystems' Java stage (Java 1.0 [J2SE]). As of December 2008, the most recent arrival of the Java Standard Edition is 6 (J2SE). With the headway of Java and its broad fame, different designs were worked to suit different sorts of stages. Ex: J2EE for Enterprise Applications, J2ME for Mobile Applications. Sun Microsystems has renamed the new J2 forms as Java SE, Java EE, and Java ME individually. Java is ensured to be Write Once, Run Anywhere. Java is:

            • Object Oriented: In Java, everything is an Object. Java can be easily extended since it is based on the Object model. 
            • Platform independent: Unlike many other programming languages including C and C++, when Java is compiled, it is not compiled into platform specific machine, rather into platform-independent bytecode. This bytecode is distributed over the web and interpreted by Virtual Machine (JVM) on whichever platform it is being run. 
            • Simple: Java is designed to be easy to learn. If you understand the basic concept of OOP Java would be easy to master. 
            • Secure: With Java's secure feature it enables to develop virus-free, tamper-free systems. Authentication techniques are based on public-key encryption. 
            • Architectural-Neutral: Java compiler generates an architecture-neutral object file format which makes the compiled code to be executable on many processors, with the presence of Java runtime system. 
            • Portable: Being architectural-neutral and having no implementation dependent aspects of the specification makes Java portable. The compiler in Java is written in ANSI C with a clean portability boundary which is a POSIX subset.
            • Robust: Java makes an effort to eliminate error-prone situations by emphasizing mainly on compile-time error checking and runtime checking.
            • Multithreaded: With Java's multithreaded feature it is possible to write programs that can do many tasks simultaneously. This design feature allows developers to construct smoothly running interactive applications.
            • Interpreted: Java bytecode is translated on the fly to native machine instructions and is not stored anywhere. The development process is more rapid and analytical since the linking is an incremental and lightweight process. 
            • High Performance: With the use of Just-In-Time compilers, Java enables high performance. 
            • Distributed: Java is designed for the distributed environment of the internet.
            • Dynamic: Java is considered to be more dynamic than C or C++ since it is designed to adapt to an evolving environment. Java programs can carry an extensive amount of run-time information that can be used to verify and resolve accesses to objects on run-time. 



            Programming Fundamentals

            Token: The smallest individual unit in a program is known as Token. Java has the following types of tokens: Keyword, Identifier, Literals, Punctuators and operators.

            Keywords: The following list shows the reserved words in Java. These reserved words may not

            be used as constant or variable or any other identifier names.


            Literals: A literal is a source code representation of a fixed value. They are represented directly in the code without any computation. Literals can be assigned to any primitive type variable. For example:

            byte, int, long, and short can be expressed in decimal(base 10), hexadecimal(base 16) or octal(base 8) number systems as well. Prefix 0 is used to indicate octal and prefix 0x indicates hexadecimal when using these number systems for literals. For example:


            String literals in Java are specified like they are in most other languages by enclosing a sequence of characters between a pair of double quotes. Examples of string literals are:


            String and char types of literals can contain any Unicode characters. For example:



            Identifiers: All Java components require names. Names used for classes, variables and methods are called identifiers. In Java, there are several points to remember about identifiers. They are as follows:
            All identifiers should begin with a letter (A to Z or a to z), currency character ($) or an underscore (_).
            After the first character identifiers can have any combination of characters.
            A keyword cannot be used as an identifier.
            Most importantly identifiers are case sensitive.
            Examples of legal identifiers: age, $ salary, _value, __1_value
            Examples of illegal identifiers: 123abc, -salary

            Java Operators: Java provides a rich set of operators to manipulate variables. We can divide all the Java operators into the following groups:

            • Arithmetic Operators 
            • Relational Operators
            • Bitwise Operators 
            • Logical Operators
            • Assignment Operators
            • Misc Operators


            The Arithmetic Operators: Arithmetic operators are used in mathematical expressions in the same way that they are used in algebra. The following table lists the arithmetic operators: Assume integer variable A holds 10 and variable B holds 20, then:



            The Relational Operators: There are following relational operators supported by Java language Assume variable A holds 10 and variable B holds 20, then:



            The Logical Operators: The following table lists the logical operators: Assume Boolean variables A holds true and variable B holds false, then:



            The Assignment Operators: There are following assignment operators supported by Java language:



            Misc Operators: There are a few other operators supported by Java Language.
            Conditional Operator ( ? : ) :- Conditional operator is also known as the ternary operator. This operator consists of three operands and is used to evaluate Boolean expressions. The goal of the operator is to decide which value should be assigned to the variable. The operator is written as:

            Variable x = (expression) ? value if true: value if false

            Following is the Example:

            int a,b;
            a=10;
            b=(a==1) ? 20:30;
            System.out.println("Value of b is :" + b);
            b=(a== 10) ? 20:30;
            System.out.println("Value of b is :" + b);

            This would produce the following  result:

            Value of b is: 30
            Value of b is: 20

            No comments:

            Post a Comment