INDEX. A SIMPLE JAVA PROGRAM Class Declaration The Main Line. The Line Contains Three Keywords The Output Line

Similar documents
Computational Expression

CIS133J. Working with Numbers in Java

PROGRAMMING FUNDAMENTALS

Java Classes: Math, Integer A C S L E C T U R E 8

Introduction to Programming Using Java (98-388)

Chapter 2: Using Data

(A) 99 (B) 100 (C) 101 (D) 100 initial integers plus any additional integers required during program execution

Character Stream : It provides a convenient means for handling input and output of characters.

Chapter 02: Using Data

COMP 250: Java Programming I. Carlos G. Oliver, Jérôme Waldispühl January 17-18, 2018 Slides adapted from M. Blanchette

LECTURE 2 (Gaya College of Engineering)

Lecture Set 4: More About Methods and More About Operators

Lecture 2. COMP1406/1006 (the Java course) Fall M. Jason Hinek Carleton University

CSC 1214: Object-Oriented Programming

3. Java - Language Constructs I

(A) 99 ** (B) 100 (C) 101 (D) 100 initial integers plus any additional integers required during program execution

B.V. Patel Institute of BMC & IT, UTU 2014

Data Types, Literals, Operators

Lecture Set 4: More About Methods and More About Operators

Full file at

1 Shyam sir JAVA Notes

CSC Java Programming, Fall Java Data Types and Control Constructs

1 class Lecture2 { 2 3 "Elementray Programming" / References 8 [1] Ch. 2 in YDL 9 [2] Ch. 2 and 3 in Sharan 10 [3] Ch.

Section 2.2 Your First Program in Java: Printing a Line of Text

Chapter 2: Using Data

Program Fundamentals

Entry Point of Execution: the main Method. Elementary Programming. Learning Outcomes. Development Process

Classes and Objects 3/28/2017. How can multiple methods within a Java class read and write the same variable?

Programming in C++ 6. Floating point data types

Operators and Expressions

Java Tutorial. Saarland University. Ashkan Taslimi. Tutorial 3 September 6, 2011

McGill University School of Computer Science COMP-202A Introduction to Computing 1

Conversions and Overloading : Overloading

false, import, new 1 class Lecture2 { 2 3 "Data types, Variables, and Operators" 4

false, import, new 1 class Lecture2 { 2 3 "Data types, Variables, and Operators" 4

Lesson 02 Data Types and Statements. MIT 11053, Fundamentals of Programming By: S. Sabraz Nawaz Senior Lecturer in MIT Department of MIT FMC, SEUSL

Getting started with Java

Zhifu Pei CSCI5448 Spring 2011 Prof. Kenneth M. Anderson

Java Bytecode (binary file)

Basics of Java Programming

C++ Important Questions with Answers

CHAPTER 3 Expressions, Functions, Output

An overview of Java, Data types and variables

Simple Java Programs. OOC 4 th Sem, B Div Prof. Mouna M. Naravani

13 th Windsor Regional Secondary School Computer Programming Competition

CS 112 Introduction to Programming

Expressions & Flow Control

CSE 431S Type Checking. Washington University Spring 2013

Chapter 2: Basic Elements of Java

1.3b Type Conversion

Building Java Programs

CIS3023: Programming Fundamentals for CIS Majors II Summer 2010

Interpreted vs Compiled. Java Compile. Classes, Objects, and Methods. Hello World 10/6/2016. Python Interpreted. Java Compiled

CS 112 Introduction to Computing II. Wayne Snyder Computer Science Department Boston University

CS2141 Software Development using C/C++ C++ Basics

Data and Variables. Data Types Expressions. String Concatenation Variables Declaration Assignment Shorthand operators. Operators Precedence

Building Java Programs

JAVA Programming Fundamentals

CS Programming I: Primitives and Expressions

CS Week 2. Jim Williams, PhD

CS 251 Intermediate Programming Methods and Classes

CS 251 Intermediate Programming Methods and More

Pace University. Fundamental Concepts of CS121 1

CSCI 135 Exam #2 Fundamentals of Computer Science I Fall 2013

Full file at

Lecture 02, Fall 2018 Friday September 7

false, import, new 1 class Lecture2 { 2 3 "Data types, Variables, and Operators" 4

CS111: PROGRAMMING LANGUAGE II

JAVA OPERATORS GENERAL

Outline. Parts 1 to 3 introduce and sketch out the ideas of OOP. Part 5 deals with these ideas in closer detail.

Section 2.2 Your First Program in Java: Printing a Line of Text

Computer Programming, I. Laboratory Manual. Final Exam Solution

3.Constructors and Destructors. Develop cpp program to implement constructor and destructor.

Lecture 5: Methods CS2301

Zheng-Liang Lu Java Programming 45 / 79

Lecture 3: C Programm

CSE 201 JAVA PROGRAMMING I. Copyright 2016 by Smart Coding School

Tester vs. Controller. Elementary Programming. Learning Outcomes. Compile Time vs. Run Time

CS110: PROGRAMMING LANGUAGE I

Elementary Programming

Chapter 2 Elementary Programming

Fall 2017 CISC124 9/16/2017

Full file at

Data Types. Every program uses data, either explicitly or implicitly to arrive at a result.

Lesson 02 Data Types and Statements. MIT 12043, Fundamentals of Programming By: S. Sabraz Nawaz Senior Lecturer in MIT Department of MIT FMC, SEUSL

false, import, new 1 class Lecture2 { 2 3 "Data types, Variables, and Operators" 4

CS 231 Data Structures and Algorithms, Fall 2016

Introduction to Programming (Java) 4/12

Programming. Syntax and Semantics

Methods and Data (Savitch, Chapter 5)

CS111: PROGRAMMING LANGUAGE II

TUGCE KEMEROZ - ASLI OZKAN - AYSE TARTAN. Week 12/02/ /02/2007 Lecture Notes:

( &% class MyClass { }

Expressions and Data Types CSC 121 Spring 2017 Howard Rosenthal

CS110D: PROGRAMMING LANGUAGE I

Outline. Performing Computations. Outline (cont) Expressions in C. Some Expression Formats. Types for Operands

Fundamentals of Programming Data Types & Methods

CS 152: Data Structures with Java Hello World with the IntelliJ IDE

Computer Components. Software{ User Programs. Operating System. Hardware

Tools : The Java Compiler. The Java Interpreter. The Java Debugger

Transcription:

A SIMPLE JAVA PROGRAM Class Declaration The Main Line INDEX The Line Contains Three Keywords The Output Line COMMENTS Single Line Comment Multiline Comment Documentation Comment TYPE CASTING Implicit Type Casting Explicit Type Casting

A SIMPLE JAVA PROGRAM class SampleOne { public static void main(string args[ ]) { System.out.println( WELCOME ); } }

CLASS DECLARATION Class SampleOne Class is a keyword and declare a new class is being defined. SampleOne is a java identifier that is name of class.

MAIN LINE THE public static void main (String args[ ]) Java program must contain the main method. It is the starting point for interpreter to being execution of program. THE LINE CONTAIN THREE KEYWORDS public:- The keyword public is access specifier therefore it is access to all other classes.

Static:- void :- The keyword static allows main to be called without having to instantiate a particular instance of class. Since main() method is called by java interpreter before any object are made. The type modifier void state that main() method does not return any type of value.

String args[ ]:- String args declares a parameter named args, which is an array of instance of class string. args receives any command line argument present when the program is executed.

The output line statement System.out.println( WELCOME ); The println method is a member of out object. Which is static data member of system class. The output of the program is WELCOME

COMMENTS IN A PROGRAM Single Line Comment ( // ) Multiline Comment (/* and */) Documentation Comment(/**and */)

SINGLE LINE COMMENT ( // ):- For a single line comment we use double slash(//) to begine comments. It end at end of line. E.g:- //program for stack operation. MULTI LINE COMMENTS ( /*AND*/ ):- For more than one line of information we use this comments. Multiline are start with /*and end with */. E.g:- /*program for stack is designed by Vijay Bhaskar*/.

DOCUMENTATION COMMENT ( /**&*/ ) For the documentation we use documentation comments. Documentation comment start with /** and end with */. Eg:- /** test of jdk Author S.P.Prabhu Version 1.0*/

TYPE CONVERSION AND CASTING Java permits mixing of constants and variables of different types, but during execution it follows type conversions. In java type casting can done using two ways. They are: 1. Implicit Type Casting 2. Explicit Type Casting

IMPLICIT TYPE CASTING:- In an expression, if the operand are of different types the lower type is automatically converted to the higher type before the operation proceeded by the java interpreter. The result is of higher type. Such type of casting is called implicit casting. In this type of casting there is no loss of data. The following are some implicit type of casting with no loss of data. From To byte short, char, int, long, float, double short char, int,long, float, double char int, long, float, double int long, float, double long float, double float double

EXPLICIT TYPE CASTING:- If we want to force to convert the operand of an expression from one type to another type depending upon user choice, such type of casting is called Explicit type casting. In explicit type casting there is a chance of data loss when we convert the operand from higher type to lower type. The process of converting value is known as casting value. E.g:-int x=(int)7.5