0% found this document useful (0 votes)
17 views31 pages

(Java Basics) For New Learners

The document discusses the basics of programming in Java, including the structure of a Java program, the use of flowcharts, and the importance of reserved words and comments. It also covers the differences between compilers and interpreters, as well as various types of operators and data types in Java. Additionally, it highlights the syntax for input and output statements in Java programming.

Uploaded by

rumpadasdas21
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
17 views31 pages

(Java Basics) For New Learners

The document discusses the basics of programming in Java, including the structure of a Java program, the use of flowcharts, and the importance of reserved words and comments. It also covers the differences between compilers and interpreters, as well as various types of operators and data types in Java. Additionally, it highlights the syntax for input and output statements in Java programming.

Uploaded by

rumpadasdas21
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 31
ber and store it in variable A fe another number and store it in variable B dA and B and store the result in variable C play the value of C nical representation of an algorithm is called the flowchart. lowchart t step after writing an algorithm Is to produce a flowchart. The flowchart is a pictoy tation of the algorithm. e four basic symbols in a flow erform. They are: [Ov you KNow (7) 4+ ‘The first flowchart was drawn by Fi i in the year 1921. es sper chart, which represent the kind of task that the comp The Start or End box The Processing box The Decision-making box Input-output box int x, Ys 25 ‘System.out.printin(“Enter three integers “)i Scanner in = new Scanner(System.in); x= in.nextint0; y in.nextint(); z= in.nextInt0); if (x>y 8&X>Z) system.out.printin(“First number |S largest.”); else if (y>x &&Y> 2) ystem.out.printin("“Seco number is largest.”); else if (z>x&&2>Y) system.out.printin Third number iS largest.”); else ystem.out.printin(“Ente e numbers are not distinct.”); ny other omponents of a Program ns written in a programming langué nallest unit of a pr is refe smponents of a prog ein _ OSadh, vedwm impact javaaaht| public Cass Poeft lays all the errors together”! » __ Interpreter ——e High Level Language (System Program) (Object Progany Differences between a Compiler and an Interpreter he whole source program 1. It converts the source Program into ject program at once. the object program one line at a tine. isplays the errors for the 2. It displays the errors, one line program together, after the time and only after debugging tht n. error the control goes to! je mex TYPES OF HIGH LEVEL LANGUAGES ligh level languages are broadly classified into three major categor ‘eg High Level Languages _ ’ Structure Ofieriten 1 cnn To support mathemati decimal both) JAVA RESERVED WORDS va reserved -words-or-the keywords are the words which. carry special meaning — the system compiler. These words are basically used for writing a Java statement. Such words cannot be used for naming a variable in the program. Some of the reserved words or keywords are listed as below: Se witch else break i cm noms int ~~ ‘double ‘t ser ie — do try for catch short a program in Java is entirely different s essential to know the following points *Comments in a program: The comment statement is a non statement in Java. It is included for the sake of the users to inders action is going to be taken in a program or statement, * Declaration of class: It contains the word, access Specifier (Le., public) defines the keyword ‘class’ which is followed by a meaningful q For example, if you are writing a program to find the sum of two m, then it could be written as public class Sum. Conventionally, the dos starts with an uppercase letters. * Declaration of main function: The main( ) function encloses the programming statements within the opening and closing curly braces { }. The main() function is further enclosed within { } under class heading. * The termination of each statement “must be indicated with a semi-colon. ~—~* The closing of curly braces indicates the closing of a block of statements, function and class. ample, Syste The message needs ou want t System: P is the variat result of the exec) Output: The sum of t Ou wm ‘TPUT STATEMENT IN JAVA PROGRAMMING he statement which is used to get the output of the program or to display Messages on the screen, is given as: System.out.println(); Syntax: For example, System.out.println(“Welcome to Java Programming”); Output: Welcome to Java Programming. The message needs to be written within double quotes (“ ”) enclosed within braces. If you want to display a message along, with a variable then it could be written as: System.out.printin(“The sum of two numbers is” + p); (Here, p is the variable, which. contains the result of the execution.) Output: The sum of two numbers is 45. le a an CHARACTER SETS The different character sets are explained as under: * Letters + All the letters of English alphabet (A-Z and a-z) can be wet. Java language, + Digits : Digits (0 = 9) can be used in Java language. * Operators : Operators can be classified in three different categories, () Arithmetical Operator: All arithmetical operators like +, -% J, applicable in Java programming, , 4© | Ove, Dur d a (i) Logical operator: In Java, &é&, ||, 1 are used as logical operator, (i), Relational operators: The Java ln Bae uses relational Jo hind out tte a sf A. 0030 $23 “cent is ‘Amit Srivastava’ Token You would have studi a functional unit of also a functional components and each individual com a. —_—— ooike various types » Literals —(onghent values eo deat alt eects _e-Tdentifierse VariahQ values Penida component of va eg ae 3? fesr@ircaning end takes pert = ne es eq _»Separators= i 8 444 bra: b snt-the scope ‘Question m: true while u For example, ma used_to-represe or a class- of a function ie. a function belonging > an obj For example, (i) Sy (ii) javaio.*, ete: sed-irvarJave progranvas. statement.terminator It indicates Any line continued ‘after the semi colon is treated as the stem.outprintinO; For example, int a =5; system.out printin(a); are treated as two separate atements in Java. ables parators vey are the the special characters in Jaya whi ‘the characters. eoron ¢ Brackets (), Curly brackets {1}, square brackets [].et€- is. jes under, ‘ke yariabl For example, Comma(,).| omma (,) in a Java prog declaration... ‘or example, int ab,<; Brackets () are used to enclose any. arithmetical or tel of statements und: urly brackets (} are ‘used to enclose a. group. ‘ement. quare_brackets.[.]. are, used to-enclose _subscript-or-the.cell- numberof. jensional array. d_to se} nal expressions lera.compound rithmetical or logical wo ), Relational Operators: / Logical Operators: &&, [|], ete. TYPES IN JAVA compiler contains a phase called the stot i : rage assi ce a ae ie ee bain to store the data efficiently. Hence, the com 1 you are likely to supply for storage to ensure optimum

You might also like