This Presentation is the intro. to java programming.
This presentation contain the basics of Java with example in simple language.
This presentation clear your all concept about programming in java and then you can easily make programs in java.
This document provides an introduction to basic Java programming concepts including variables, data types, identifiers, keywords, comments, and outputting variable values. It discusses the different primitive data types in Java like int, double, char, etc. and how to declare and initialize variables of these types. The document also covers Java naming conventions for classes, methods and variables. It explains how to write single line, multi-line and javadoc comments. Finally, it demonstrates how to use System.out.println() and System.out.print() to output the values of variables.
This document provides an overview of topics to be covered in a Zend PHP Certification tutorial being held from October 18-21, 2005 in San Francisco, CA. The tutorial will cover PHP language fundamentals like tags, data types, variables, operators, conditionals, and iterators to help attendees prepare for the PHP 4 certification exam. It also briefly outlines the exam format and structure of the tutorial sessions.
This document provides an overview of advanced Java programming concepts covered in the unit, including object-oriented programming, data types, variables, arrays, operators, inheritance, and control statements. It defines key concepts like classes, objects, encapsulation, polymorphism, and inheritance. For data types, it covers primitive types like int, float, boolean and char, as well as arrays. Operators covered include unary, arithmetic, relational, logical, and assignment operators. The document also discusses variables, arrays, and control statements like selection, iteration, and jump statements.
The document outlines an agenda for learning core Java concepts over 15 sections. It introduces key Java topics like primitive data types, variables, arrays, control flow statements, classes and objects, inheritance, polymorphism, exceptions, strings and characters, files and streams, and generic collections. The agenda also covers defining classes and methods, passing arguments, encapsulation, and memory concepts like objects, references, and the heap.
This document provides an introduction and overview of PL/SQL. It discusses that PL/SQL is Oracle's procedural language extension for SQL and allows for transactions processing and block structuring. The document then covers various PL/SQL concepts like blocks, data types, control structures, variables and SQL operations within PL/SQL code.
The document discusses various Java programming concepts including comments, identifiers, keywords, primitive data types, variables, objects, and access modifiers. It provides examples and definitions for each concept. The key points covered are the eight primitive data types in Java (boolean, char, byte, short, int, long, float, double), how to declare and initialize variables, how to construct objects using the new keyword, and the differences between public, private, protected, default, final, and abstract access modifiers.
This document discusses Java data types and variables. It defines variables as containers that hold data values and notes there are three types: local, instance, and static. Local variables are declared within methods while instance variables are declared in a class but outside methods. Static variables can be accessed by the class name. The document also outlines Java's primitive data types like int and double, and non-primitive types like Strings and Arrays. It explains type casting between primitive types and differences between primitive and non-primitive data types.
This document provides an overview of object-oriented programming (OOP) concepts in C#, including classes, objects, inheritance, encapsulation, and polymorphism. It defines key terms like class and object, and explains how C# supports OOP principles such as defining classes with methods and properties, extending classes through inheritance, hiding implementation through encapsulation, and allowing polymorphic behavior through function overloading and overriding. Abstract classes and sealed modifiers are also covered. The document is intended to help explain basic OOP concepts in C# to readers.
This document provides an introduction to basic Java programming concepts including variables, data types, identifiers, keywords, comments, and outputting variable values. It discusses the different primitive data types in Java like int, double, char, etc. and how to declare and initialize variables of these types. The document also covers Java naming conventions for classes, methods and variables. It explains how to write single line, multi-line and javadoc comments. Finally, it demonstrates how to use System.out.println() and System.out.print() to output the values of variables.
This document provides an overview of topics to be covered in a Zend PHP Certification tutorial being held from October 18-21, 2005 in San Francisco, CA. The tutorial will cover PHP language fundamentals like tags, data types, variables, operators, conditionals, and iterators to help attendees prepare for the PHP 4 certification exam. It also briefly outlines the exam format and structure of the tutorial sessions.
This document provides an overview of advanced Java programming concepts covered in the unit, including object-oriented programming, data types, variables, arrays, operators, inheritance, and control statements. It defines key concepts like classes, objects, encapsulation, polymorphism, and inheritance. For data types, it covers primitive types like int, float, boolean and char, as well as arrays. Operators covered include unary, arithmetic, relational, logical, and assignment operators. The document also discusses variables, arrays, and control statements like selection, iteration, and jump statements.
The document outlines an agenda for learning core Java concepts over 15 sections. It introduces key Java topics like primitive data types, variables, arrays, control flow statements, classes and objects, inheritance, polymorphism, exceptions, strings and characters, files and streams, and generic collections. The agenda also covers defining classes and methods, passing arguments, encapsulation, and memory concepts like objects, references, and the heap.
This document provides an introduction and overview of PL/SQL. It discusses that PL/SQL is Oracle's procedural language extension for SQL and allows for transactions processing and block structuring. The document then covers various PL/SQL concepts like blocks, data types, control structures, variables and SQL operations within PL/SQL code.
The document discusses various Java programming concepts including comments, identifiers, keywords, primitive data types, variables, objects, and access modifiers. It provides examples and definitions for each concept. The key points covered are the eight primitive data types in Java (boolean, char, byte, short, int, long, float, double), how to declare and initialize variables, how to construct objects using the new keyword, and the differences between public, private, protected, default, final, and abstract access modifiers.
This document discusses Java data types and variables. It defines variables as containers that hold data values and notes there are three types: local, instance, and static. Local variables are declared within methods while instance variables are declared in a class but outside methods. Static variables can be accessed by the class name. The document also outlines Java's primitive data types like int and double, and non-primitive types like Strings and Arrays. It explains type casting between primitive types and differences between primitive and non-primitive data types.
This document provides an overview of object-oriented programming (OOP) concepts in C#, including classes, objects, inheritance, encapsulation, and polymorphism. It defines key terms like class and object, and explains how C# supports OOP principles such as defining classes with methods and properties, extending classes through inheritance, hiding implementation through encapsulation, and allowing polymorphic behavior through function overloading and overriding. Abstract classes and sealed modifiers are also covered. The document is intended to help explain basic OOP concepts in C# to readers.
Java is an object-oriented programming language. It has keywords, primitive data types like int and double, and variables that are declared with a type. Variables can be initialized statically at declaration or dynamically later. Constants are declared with final and can't be changed.
This document provides an introduction and overview of various C# concepts including references and value types, arrays, generics, collections like List<T>, foreach loops, graphics drawing with System.Drawing.Graphics, and keyboard input handling using events like KeyDown, KeyPress, and KeyUp. It includes code examples and explanations of commonly used classes.
This document outlines a lecture on elements of the C++ language, including variables, datatypes, and constants. It discusses that variables are names that represent memory locations used to store changing values. Datatypes specify what type of data (integer, float, char, etc.) a variable can hold. Variables must be declared before use with their datatype. Initialization assigns an initial value. Constants are like variables but their values cannot change once assigned. The lecture covers declaring, initializing, and defining variables and constants in C++. Examples of code are provided.
This document provides an overview of the Java programming language. It discusses key Java concepts like object-oriented programming, classes, objects, inheritance, encapsulation and the Java API. It also describes how to write Java applets and applications, common errors, and the lifecycle of an applet.
This document provides an overview of object-oriented programming concepts using C++. It discusses key OOP concepts like objects, classes, encapsulation, inheritance, polymorphism, and dynamic binding. It also covers C++ specific topics like functions, arrays, strings, modular programming, and classes and objects in C++. The document is intended to introduce the reader to the fundamentals of OOP using C++.
Closures allow blocks of code to access variables from the enclosing scope even after the scope has closed. This allows closures to maintain state even when passed around or returned from functions. Closures originated in Lisp and are supported in many modern languages like Python, Ruby, and C#, providing benefits like elegant iteration, filtering, and caching of results. While objects can also be used to inject strategy or share state, closures provide a more concise syntax and avoid wrapper classes in many cases.
Object Oriented Programming using C++ Part IAjit Nayak
This document provides an introduction to object-oriented programming using C++. It outlines the topics that will be covered in the course, including fundamentals, simple programs, operators, data types, namespaces, function prototypes, references, default arguments, function overloading, and inline functions. It discusses the motivation for learning OOP and C++. The document also contains examples of simple C++ programs and explanations of concepts like function prototypes, call by value/reference, and overloading. The goal of the course is to understand object-oriented thinking and become familiar with programming in C++.
Indexers, Partial Class And Partial MethodGopal Ji Singh
This PDF is related to Rajpat Systems Part. This PDF contains Indexers in C#, Partial Classes in C#, Partial Method in C#,
"Knowledge Is Free Lets Share It"
This document provides an overview of key Java concepts including:
- Classes define blueprints for objects with states and behaviors.
- Objects are instances of classes that store their unique state in fields and expose behaviors through methods.
- Other concepts covered include variables, primitive data types, arrays, operators, control flow statements, passing arguments to methods, and the difference between passing primitive and reference types. The document serves as an introduction for learning Java.
In this you learn about
Access Modifiers in Java / Visibility Modifiers in Java
1. Default access modifier
2. private access modifier
3. protected access modifier
4. public access modifier
This document introduces C# and object-oriented programming concepts. It discusses event-driven programming, using objects to model problems, and the basic elements of objects like classes, fields, methods, and properties. It provides examples of modeling word processors, strategy games, and operating systems with objects. The document also demonstrates creating a simple GUI application without designers and discusses namespaces, instantiation, and calling methods and properties in C#.
Here is a Python class with the specifications provided in the question:
class PICTURE:
def __init__(self, pno, category, location):
self.pno = pno
self.category = category
self.location = location
def FixLocation(self, new_location):
self.location = new_location
This defines a PICTURE class with three instance attributes - pno, category and location as specified in the question. It also defines a FixLocation method to assign a new location as required.
The document discusses four approaches to implementing higher-kinded types in the Dotty compiler: the simple encoding, projection encoding, refinement encoding, and direct representation. It describes each approach and its limitations. The simple encoding provides a modest way to support basic higher-kinded concepts but has difficulty explaining legality. The projection and refinement encodings had problems and were ultimately less successful than initially hoped. A direct representation of higher-kinded types through special type forms was needed for robust support. While compiler hacking validated ideas, a better theoretical foundation relating higher-kinded types to the DOT calculus may have avoided some experiments.
The document discusses key concepts in Java including classes, objects, methods, and command line arguments. A class defines common properties and behaviors for objects through fields and methods. Objects are instantiated from classes and can access fields and methods using dot notation. Command line arguments allow passing data into a Java application and are accessed through the args parameter in the main method.
Collections fornece classes para estruturas de dados como listas, conjuntos e mapas. Listas mantêm uma ordem e permitem elementos duplicados. Conjuntos não permitem duplicados e não garantem ordem. Mapas mapeiam chaves para valores.
This document provides concepts to memorize for the Oracle Certificate Associate Java 7 exam. It includes summaries of topics like default constructors, legal vs illegal class declarations, interfaces, methods, numbers, floating point numbers, boxing and unboxing, literals, operators, strings, arrays, collections, loops, and common mistakes. The document is from a personal note and is not an official Java course, but rather concepts to commit to memory for the exam. It cites three books as references for additional study material.
The document contains 4 code snippets demonstrating different ways to take input in Java programs:
1) Using command line arguments and the args array to print a greeting with a passed in name
2) Swapping two integers entered from the keyboard using only two variables
3) Reading input from the keyboard using InputStreamReader and BufferedReader classes
4) Taking input using the Scanner class to read an integer, string, and double from console input
c++ programming Unit 3 variables,data typesAAKASH KUMAR
This document discusses variables and data types in C++. It defines variables as storage locations that can hold values of a particular data type. Variables must be declared with a data type and can optionally be initialized. The document covers integer, float, and character data types. It also provides examples of declaring, initializing, and using variables in simple programs to calculate sums and areas.
The Java Collections Framework provides a unified architecture for representing and manipulating collections of objects. The framework includes collection interfaces like Set, List, Queue, and Map that define common operations on collections. It also includes general-purpose implementations of these interfaces like HashSet, ArrayList, LinkedList, HashMap, and TreeMap that are backed by common data structures like arrays, linked lists, and trees. The framework aims to allow collections to be manipulated independently of their specific representation.
Java is an object-oriented programming language. It has keywords, primitive data types like int and double, and variables that are declared with a type. Variables can be initialized statically at declaration or dynamically later. Constants are declared with final and can't be changed.
This document provides an introduction and overview of various C# concepts including references and value types, arrays, generics, collections like List<T>, foreach loops, graphics drawing with System.Drawing.Graphics, and keyboard input handling using events like KeyDown, KeyPress, and KeyUp. It includes code examples and explanations of commonly used classes.
This document outlines a lecture on elements of the C++ language, including variables, datatypes, and constants. It discusses that variables are names that represent memory locations used to store changing values. Datatypes specify what type of data (integer, float, char, etc.) a variable can hold. Variables must be declared before use with their datatype. Initialization assigns an initial value. Constants are like variables but their values cannot change once assigned. The lecture covers declaring, initializing, and defining variables and constants in C++. Examples of code are provided.
This document provides an overview of the Java programming language. It discusses key Java concepts like object-oriented programming, classes, objects, inheritance, encapsulation and the Java API. It also describes how to write Java applets and applications, common errors, and the lifecycle of an applet.
This document provides an overview of object-oriented programming concepts using C++. It discusses key OOP concepts like objects, classes, encapsulation, inheritance, polymorphism, and dynamic binding. It also covers C++ specific topics like functions, arrays, strings, modular programming, and classes and objects in C++. The document is intended to introduce the reader to the fundamentals of OOP using C++.
Closures allow blocks of code to access variables from the enclosing scope even after the scope has closed. This allows closures to maintain state even when passed around or returned from functions. Closures originated in Lisp and are supported in many modern languages like Python, Ruby, and C#, providing benefits like elegant iteration, filtering, and caching of results. While objects can also be used to inject strategy or share state, closures provide a more concise syntax and avoid wrapper classes in many cases.
Object Oriented Programming using C++ Part IAjit Nayak
This document provides an introduction to object-oriented programming using C++. It outlines the topics that will be covered in the course, including fundamentals, simple programs, operators, data types, namespaces, function prototypes, references, default arguments, function overloading, and inline functions. It discusses the motivation for learning OOP and C++. The document also contains examples of simple C++ programs and explanations of concepts like function prototypes, call by value/reference, and overloading. The goal of the course is to understand object-oriented thinking and become familiar with programming in C++.
Indexers, Partial Class And Partial MethodGopal Ji Singh
This PDF is related to Rajpat Systems Part. This PDF contains Indexers in C#, Partial Classes in C#, Partial Method in C#,
"Knowledge Is Free Lets Share It"
This document provides an overview of key Java concepts including:
- Classes define blueprints for objects with states and behaviors.
- Objects are instances of classes that store their unique state in fields and expose behaviors through methods.
- Other concepts covered include variables, primitive data types, arrays, operators, control flow statements, passing arguments to methods, and the difference between passing primitive and reference types. The document serves as an introduction for learning Java.
In this you learn about
Access Modifiers in Java / Visibility Modifiers in Java
1. Default access modifier
2. private access modifier
3. protected access modifier
4. public access modifier
This document introduces C# and object-oriented programming concepts. It discusses event-driven programming, using objects to model problems, and the basic elements of objects like classes, fields, methods, and properties. It provides examples of modeling word processors, strategy games, and operating systems with objects. The document also demonstrates creating a simple GUI application without designers and discusses namespaces, instantiation, and calling methods and properties in C#.
Here is a Python class with the specifications provided in the question:
class PICTURE:
def __init__(self, pno, category, location):
self.pno = pno
self.category = category
self.location = location
def FixLocation(self, new_location):
self.location = new_location
This defines a PICTURE class with three instance attributes - pno, category and location as specified in the question. It also defines a FixLocation method to assign a new location as required.
The document discusses four approaches to implementing higher-kinded types in the Dotty compiler: the simple encoding, projection encoding, refinement encoding, and direct representation. It describes each approach and its limitations. The simple encoding provides a modest way to support basic higher-kinded concepts but has difficulty explaining legality. The projection and refinement encodings had problems and were ultimately less successful than initially hoped. A direct representation of higher-kinded types through special type forms was needed for robust support. While compiler hacking validated ideas, a better theoretical foundation relating higher-kinded types to the DOT calculus may have avoided some experiments.
The document discusses key concepts in Java including classes, objects, methods, and command line arguments. A class defines common properties and behaviors for objects through fields and methods. Objects are instantiated from classes and can access fields and methods using dot notation. Command line arguments allow passing data into a Java application and are accessed through the args parameter in the main method.
Collections fornece classes para estruturas de dados como listas, conjuntos e mapas. Listas mantêm uma ordem e permitem elementos duplicados. Conjuntos não permitem duplicados e não garantem ordem. Mapas mapeiam chaves para valores.
This document provides concepts to memorize for the Oracle Certificate Associate Java 7 exam. It includes summaries of topics like default constructors, legal vs illegal class declarations, interfaces, methods, numbers, floating point numbers, boxing and unboxing, literals, operators, strings, arrays, collections, loops, and common mistakes. The document is from a personal note and is not an official Java course, but rather concepts to commit to memory for the exam. It cites three books as references for additional study material.
The document contains 4 code snippets demonstrating different ways to take input in Java programs:
1) Using command line arguments and the args array to print a greeting with a passed in name
2) Swapping two integers entered from the keyboard using only two variables
3) Reading input from the keyboard using InputStreamReader and BufferedReader classes
4) Taking input using the Scanner class to read an integer, string, and double from console input
c++ programming Unit 3 variables,data typesAAKASH KUMAR
This document discusses variables and data types in C++. It defines variables as storage locations that can hold values of a particular data type. Variables must be declared with a data type and can optionally be initialized. The document covers integer, float, and character data types. It also provides examples of declaring, initializing, and using variables in simple programs to calculate sums and areas.
The Java Collections Framework provides a unified architecture for representing and manipulating collections of objects. The framework includes collection interfaces like Set, List, Queue, and Map that define common operations on collections. It also includes general-purpose implementations of these interfaces like HashSet, ArrayList, LinkedList, HashMap, and TreeMap that are backed by common data structures like arrays, linked lists, and trees. The framework aims to allow collections to be manipulated independently of their specific representation.
The document contains code snippets from 3 weekly coding assignments:
1) A Java program to check if a string is a palindrome. It compares characters at the beginning and end of the string.
2) A Java program to sort a list of names in ascending order using string comparison and swapping.
3) A Java program to count the frequency of words in a given text by tokenizing, sorting, and printing the words.
The Java Collections Framework provides interfaces and implementations for commonly used data structures like lists, sets, maps and queues. The core interfaces like Collection, List, Set, Queue and Map define the common operations for each type of data structure. General purpose implementations provided for these interfaces include ArrayList, LinkedList, HashSet, TreeSet, HashMap and TreeMap. Additional wrapper and convenience implementations add functionality like synchronization or provide optimized versions for specific use cases.
This document contains information about a student named Jitin J Pillai enrolled in the Instrumentation and Control branch of B.E. at Shantilal Shah Government Engineering College in Bhavnagar, Gujarat, India. It provides an overview of the basics of C programming including introductions to preprocessing, compiling, linking, variable types, operator precedence, type conversion, control flow, and scope rules.
This document provides an overview of Java collections including common implementations like lists, maps, and queues. It discusses how collections allow storing and accessing multiple objects, the benefits of generics for type safety, and useful methods in the Collections class for sorting, shuffling, and copying collections. Code examples are provided for creating parameterized lists and maps, sorting lists using Comparator, and exercises for working with collections in practice.
This document provides an introduction to Java programming concepts such as data types, variables, operators, input/output, control flow, methods, and classes. It explains what computer science and programming are, gives examples of basic Java programs using print statements, and discusses programming fundamentals like program structure, naming conventions, comments, and static methods. Methods are introduced as a way to organize code and eliminate redundancy. Overall, the document orients the reader to fundamental Java programming concepts.
This document provides biographies and credentials for several Java experts: Branko Mihaljević, Tihomir Smuđ, and Aleksander Radovan. It also discusses Java certification pathways including Oracle Certified Associate (OCA), Oracle Certified Professional (OCP), Oracle Certified Expert (OCE), and Oracle Certified Master (OCM) certifications. Details are given on certification exams, objectives, prerequisites, and example questions. Overall the document serves as an introduction to Java certification for developers.
The document provides code examples for several basic Java programs, including:
1) A program that compares two numbers and prints which is greater.
2) A program that takes a number as input and prints all even numbers between 1 and the input.
3) Programs that calculate the area and perimeter of shapes like circles and rectangles.
4) Programs that calculate the factorial of a number and construct a triangle shape using asterisks.
5) A program that finds and lists all leap years between two given years.
This document provides an overview of C programming basics including character sets, tokens, keywords, variables, data types, and control statements in C language. Some key points include:
- The C character set includes lowercase/uppercase letters, digits, special characters, whitespace, and escape sequences.
- Tokens in C include operators, special symbols, string constants, identifiers, and keywords. There are 32 reserved keywords that should be in lowercase.
- Variables are named locations in memory that hold values. They are declared with a data type and initialized by assigning a value.
- C has primary data types like int, float, char, and double. Derived types include arrays, pointers, unions, structures,
The document discusses event handling and exceptions in Java. It covers event-driven programming, event classes, listeners, and delegation models. It also covers exception handling, common exception types like IOException and NullPointerException, using try/catch blocks to handle exceptions, and best practices for exception handling in Java programs.
This is the Complete course of C Programming Language for Beginners. All Topics of C programming Language are covered in this single power point presentation.
Visit: www.cyberlabzone.com
This document provides an introduction and overview of the Java programming language. It discusses that Java was developed by Sun Microsystems in 1991, is an object-oriented programming language that is compiled and interpreted, and is platform independent. The document then lists key features of Java, how to write a simple Java program, features of object-oriented programming in Java including classes, objects, encapsulation, inheritance and polymorphism. It also discusses exceptions, multithreading, and provides a simple example Java program.
This document discusses basic object-oriented programming concepts in Java, including classes, objects, instance variables, methods, constructors, and the "this" keyword. It provides examples of defining a Ship class with fields like location and speed, and methods like move() and printLocation(). Constructors are used to initialize new Ship objects, and the "this" keyword differentiates instance variables from local variables within methods.
TOPS Technologies Leading IT Training Institute offer training in Php, .Net, Java, iPhone, Android, Software testing and SEO. By TOPS Technologies. http://www.tops-int.com
demo1 java of demo 1 java with demo 1 java.pptFerdieBalang
This document provides an introduction to the structure and key concepts of Java programming. It covers topics such as the structure of Java programs, keywords and identifiers, primitive data types, variables, expressions and statements, conditional and loop statements, and using the Java API. The document also discusses how Java programs are written by defining classes with a main method, compiling the source code, and running the compiled code.
This document provides an overview of the Java programming language, including its structure, keywords, data types, variables, operators, expressions, statements, and control flow structures. It discusses the structure of Java programs, including classes, packages, and the main method. It also covers Java APIs, documentation, errors, and examples of basic Java programs.
This document discusses Java variables, data types, and operators. It covers the basics of declaring variables in Java, including primitive and non-primitive data types. It also describes different types of variables, literals, casting, and operators such as arithmetic, assignment, comparison, and logical operators. Examples are provided to demonstrate variable declaration and usage of various operators.
Java is a popular object-oriented programming language. It was developed by Sun Microsystems in 1995 and is considered a robust, secure, and portable language. Some key features of Java include being platform independent, object-oriented, and having automatic memory management. Java code is compiled to bytecode that runs on a Java Virtual Machine (JVM). The JRE provides the runtime environment for Java applications. Common applications of Java include desktop programs, web applications, and enterprise software. Objects in Java are instances of classes that have state and behavior.
This document provides an overview of Java keywords, primitive data types, wrapper classes, variables, expressions, comments, casting, and overflow. It discusses the 50 Java keywords like abstract and boolean. It describes the 8 primitive types (boolean, char, byte, short, int, long, float, double), their ranges, and literals. It introduces the wrapper classes that correspond to each primitive type, like Integer for int. It also covers variables, expressions, single-line and multi-line comments, identity/widening/narrowing conversions during casting, and how overflow is handled for integer vs floating-point values.
This document summarizes key concepts from Chapter 2 of a Computer Programming I course, including:
- The structure of a Java program and how to save, compile, and run Java files.
- Using variables to store and represent data in Java, including data types, naming conventions, and assignment statements.
- How to select the proper data types for numerical variables and initialize variables.
- Using simple keyboard input and screen output in Java programs.
This document provides information on Java programming concepts including classes, methods, variables, basic program structure, data types, arithmetic operators, and access modifiers. It defines conventions for naming classes, methods, and variables. It also explains the main method structure, use of comments, wrapper classes, and conditional operators.
This document discusses data types in C programming. It introduces the four basic data types - integer, float, char, and void. Integer is used for whole numbers, float for numbers with decimals, char for single characters, and void for functions without return values. Variables must be declared with a data type before use. Standard input and output functions like scanf and printf are demonstrated for getting user input and displaying output.
The document provides an overview of the basics of Java programming. It covers the evolution of programming languages, popular languages in 2018, the history of Java, Java modules like J2SE, J2EE and J2ME. It also discusses why Java is chosen, applications of Java, and key concepts like JDK, JRE, JVM. The document then explains how to create Java code, variables and data types, arrays, Strings, and the Object class in Java.
C is a general-purpose programming language initially developed for system development like operating systems. It produces efficient code nearly as fast as assembly language. The document provides an overview of basic C programming concepts including data types, variables, functions, arrays, structures, pointers, strings, input/output operations, and preprocessor directives. It also gives examples of basic "Hello World" program structure and syntax.
Full CSE 310 Unit 1 PPT.pptx for java languagessuser2963071
This document discusses Java programming fundamentals including naming conventions, data types, literals, and writing a basic Java program. It covers lowercase and uppercase naming rules for variables, methods, and classes. It also describes numeric, boolean, character, and string literals. Key data types like int, float, char, and their ranges are explained. The document provides examples of type conversion, casting, and type promotion in expressions. It concludes with steps for compiling and running a Java program.
C Tutorial, Clanguage,
C Programming Tutorial
C - Home
C - Overview
C - Environment Setup
C - Program Structure
C - Basic Syntax
C - Data Types
C - Variables
C - Constants
C - Storage Classes
C - Operators
C - Decision Making
C - Loops
C - Functions
C - Scope Rules
C - Arrays
C - Pointers
C - Strings
C - Structures
C - Unions
C - Bit Fields
C - Typedef
C - Input & Output
C - File I/O
C - Preprocessors
C - Header Files
C - Type Casting
C - Error Handling
C - Recursion
C - Variable Arguments
C - Memory Management
C - Command Line Arguments
Variables, constants, I/O functions & Header Files document discusses:
1. Variables in C - Variables store data in memory locations and can change value. They are declared with a data type and name.
2. Constants in C - Constants cannot change value once declared. They include integer, floating point, character, and string literals.
3. Input/output functions in C - These allow programs to accept input and display output. Formatted functions like printf() and scanf() control formatting while unformatted functions like getch() and putch() do not.
4. Header files in C - Header files contain predefined library functions and are included using #include to access standard functions.
Dart is an open-source programming language developed by Google that is used to build web, server, and mobile applications. It is designed to be familiar to developers from languages like JavaScript, Java, and C# but also supports strong typing. Dart aims to help developers build complex, high-fidelity client apps for the modern web. It compiles to JavaScript to run in the browser or to native code to run mobile apps. Dart supports key features like classes, mixins, asynchronous programming, and isolates for concurrency.
This document introduces Java programming concepts including object-oriented programming, primitive data types, control structures, predefined classes like Math and String, writing and documenting classes, and summarizing key characteristics of Java like being platform independent. It also covers topics like processing Java code, defining and using classes and objects, arrays, input/output streams, and more.
This document provides an overview of object oriented programming concepts in Java including classes, objects, encapsulation, inheritance, polymorphism and more. It also outlines the syllabus for a course on OOP with Java, covering topics like arrays, strings, vectors, exception handling, GUI programming and more. Finally, it provides some examples of basic Java code.
The document provides an overview of the Java programming language. It discusses Java topics like data types, variables, arrays, input/output. It lists commonly used Java integrated development environments and provides examples of declaring variables and using primitive data types, accessing array elements, and writing a simple program to sum array values.
This document provides an introduction to Swift 2 and covers various Swift language basics including variables and constants, arrays, optionals, functions and closures, classes, structs, enums, protocols, and generics. It discusses syntax, properties, methods and gives examples for each language feature. The document is organized into sections for each language concept and provides code samples and explanations.
The document outlines an entity-relationship model for hospital management including entities such as Hospital, Doctor, Patient, Labs, and Rooms. A Hospital has Doctors and Labs, Doctors treat Patients and conduct Tests in Labs, Patients undergo Tests and are Admitted to Rooms, and relationships define characteristics and connections between entities like Doctor specializations and Patient medical information.
This document describes an entity-relationship model for a financial accounting system. The model includes entities like shipping, customers, items, orders, and carts as well as their attributes and relationships. For example, an order can contain multiple items and is placed by a customer, while a cart precedes an order and can contain multiple items.
This document outlines an entity-relationship model for a railway reservation system. The model shows the relationships between offices, trains, routes, tickets, and passengers. Offices book trains, which travel along routes between stations. Tickets are booked for passengers traveling on specific trains along routes between stations. The model tracks identifying information for offices, trains, routes, tickets, and passengers.
This document outlines an entity-relationship diagram for a library management system. It shows the entities of Library, Books, Employee, Student, and Issue and describes the attributes and relationships between them. The Library manages Books and Issues them to Students and Employees, who are identified by attributes like name, code, contact number, and address. Books have attributes like name, code, author, and issue and submission dates.
Neural interfacing research aims to develop brain-machine interfaces that can help restore sensory and motor function for impaired individuals. This includes both invasive interfaces using implanted electrodes and non-invasive interfaces using EEG. The goal is to link the nervous system to external devices for treatment or assistance. Challenges include training subjects to control interfaces and addressing ethical concerns about privacy and brain effects. If developed further, neural interfaces show potential for medical applications like prosthetics and treating disorders, as well as gaming, communication, and cognitive augmentation.
The document discusses Blue Eyes technology, which aims to create machines with human-like sensory abilities. It describes two types of emotional sensory devices: an Emotion Mouse that detects temperature and infrared signals from the hand, and Expression Glasses that track interest and confusion levels based on eye movement and gaze. The Blue Eyes system uses a Data Acquisition Unit to collect physiological sensor data from operators and send it over Bluetooth to the Central System Unit for real-time analysis and alarm triggering if needed. Potential applications include monitoring operators in power stations, aircraft control centers, and vehicles to help prevent accidents. Future enhancements could allow household devices to function based on eye gaze and voice commands.
This document discusses computer forensics. It defines computer forensics as the process of identifying, preserving, analyzing and presenting digital evidence in a legally acceptable manner. It notes that computer forensics has evolved over 30 years as law enforcement and the military have increasingly encountered technology-related crimes. The main goal of computer forensics experts is to find evidence of crimes and present that evidence in court. Key skills required for computer forensics include technical knowledge, analytical abilities, and understanding of evidence handling procedures.
Backtrack is a Linux-based penetration testing distribution containing a collection of security-related tools. It was originally developed as a live CD for security audits and designed to not leave traces after use. Backtrack contains tools for information gathering, vulnerability assessment, exploitation, maintaining access, and forensics. It is widely used by security professionals and integrates tools like Metasploit, Aircrack-NG, and Wireshark.
This document provides instructions for creating a password protected folder without using additional software. It involves copying code into Notepad and saving it as a .bat file. Running the .bat file will create a folder called "Gift" that is hidden and locked. Entering the correct password of "7448264" in the command prompt will unlock the folder and allow access to contents. The code uses batch scripting and commands to rename the folder with a long cryptic name, set attributes to hide and lock it, and check password input for access.
The code defines a Vehicle class with a constructor that prints "Vehicle is created". It also defines a Bike class that extends Vehicle, with its own constructor that first calls the Vehicle constructor using super(), then prints "Bike is created". The main method creates a Bike object, which results in output showing that both the Vehicle and Bike constructors were invoked.
This Java program uses a for loop to check if a user-input number is prime or not. The program takes the number as input, divides it by all integers from 2 to the number/2, and checks if any division results in a remainder of 0. If no remainders are 0, the number is prime and the program prints that it is prime; otherwise, it is not prime and the program prints that it is not prime.
The document shows an example of method overriding using abstract methods. It defines classes A, B, and C where B and C extend class A. Class A contains a getA() method that prints a message. Classes B and C override this method by defining their own getB() and getC() methods, with B calling the superclass method and both printing additional messages. The main method creates instances of B and C and calls their respective methods to demonstrate method overriding.
This document discusses how to achieve multiple inheritance in Java using interfaces. It defines two interfaces, Father and Mother, that each contain a float variable and method to get height. A Child class implements both interfaces and overrides the height method to calculate and print the average height from the interfaces. The code is tested in a main method that creates a Child object and calls its height method.
This Java program demonstrates method overriding. It defines a wallet class with dimensions and a salary method that returns 0. Monthly and annual classes extend wallet, overriding the salary method to return the product of the dimensions, and printing the appropriate salary text. The main method creates instances of each class, assigns them to a wallet reference variable, and calls salary to print the results.
This document contains code that implements inheritance and method overloading. It defines a base mob class with getmob and putmob methods to retrieve and display student roll number and name. The drive class inherits from mob and overloads getdrive and putdrive methods to also retrieve and display subject marks. The pen class inherits from drive and overloads getresult and putresult methods to calculate and display the total marks. The main method creates a pen object and calls its methods.
The document defines a Sum class with three overloaded add() methods that take in different parameter types (two ints, three ints, and an int and float) and return the sum. It then creates a main method in an Overloading class that creates a Sum object and calls each add() method, passing different parameters to demonstrate function overloading.
The code defines a Bike class with a final integer field speedlimit that is initialized to 70 in the constructor. The main method creates a new Bike object, which prints out the maximum speed limit of 70.
This code defines a class called "different" with integer instance variables a, b, and c. It initializes two objects of this class, mob and code, with different values for a, b, and c. It then calculates the product of a, b, and c for each object and prints the results.
Andreas Schleicher presents PISA 2022 Volume III - Creative Thinking - 18 Jun...EduSkills OECD
Andreas Schleicher, Director of Education and Skills at the OECD presents at the launch of PISA 2022 Volume III - Creative Minds, Creative Schools on 18 June 2024.
Level 3 NCEA - NZ: A Nation In the Making 1872 - 1900 SML.pptHenry Hollis
The History of NZ 1870-1900.
Making of a Nation.
From the NZ Wars to Liberals,
Richard Seddon, George Grey,
Social Laboratory, New Zealand,
Confiscations, Kotahitanga, Kingitanga, Parliament, Suffrage, Repudiation, Economic Change, Agriculture, Gold Mining, Timber, Flax, Sheep, Dairying,
This presentation was provided by Rebecca Benner, Ph.D., of the American Society of Anesthesiologists, for the second session of NISO's 2024 Training Series "DEIA in the Scholarly Landscape." Session Two: 'Expanding Pathways to Publishing Careers,' was held June 13, 2024.
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptxEduSkills OECD
Iván Bornacelly, Policy Analyst at the OECD Centre for Skills, OECD, presents at the webinar 'Tackling job market gaps with a skills-first approach' on 12 June 2024
Elevate Your Nonprofit's Online Presence_ A Guide to Effective SEO Strategies...TechSoup
Whether you're new to SEO or looking to refine your existing strategies, this webinar will provide you with actionable insights and practical tips to elevate your nonprofit's online presence.
THE SACRIFICE HOW PRO-PALESTINE PROTESTS STUDENTS ARE SACRIFICING TO CHANGE T...indexPub
The recent surge in pro-Palestine student activism has prompted significant responses from universities, ranging from negotiations and divestment commitments to increased transparency about investments in companies supporting the war on Gaza. This activism has led to the cessation of student encampments but also highlighted the substantial sacrifices made by students, including academic disruptions and personal risks. The primary drivers of these protests are poor university administration, lack of transparency, and inadequate communication between officials and students. This study examines the profound emotional, psychological, and professional impacts on students engaged in pro-Palestine protests, focusing on Generation Z's (Gen-Z) activism dynamics. This paper explores the significant sacrifices made by these students and even the professors supporting the pro-Palestine movement, with a focus on recent global movements. Through an in-depth analysis of printed and electronic media, the study examines the impacts of these sacrifices on the academic and personal lives of those involved. The paper highlights examples from various universities, demonstrating student activism's long-term and short-term effects, including disciplinary actions, social backlash, and career implications. The researchers also explore the broader implications of student sacrifices. The findings reveal that these sacrifices are driven by a profound commitment to justice and human rights, and are influenced by the increasing availability of information, peer interactions, and personal convictions. The study also discusses the broader implications of this activism, comparing it to historical precedents and assessing its potential to influence policy and public opinion. The emotional and psychological toll on student activists is significant, but their sense of purpose and community support mitigates some of these challenges. However, the researchers call for acknowledging the broader Impact of these sacrifices on the future global movement of FreePalestine.
🔥🔥🔥🔥🔥🔥🔥🔥🔥
إضغ بين إيديكم من أقوى الملازم التي صممتها
ملزمة تشريح الجهاز الهيكلي (نظري 3)
💀💀💀💀💀💀💀💀💀💀
تتميز هذهِ الملزمة بعِدة مُميزات :
1- مُترجمة ترجمة تُناسب جميع المستويات
2- تحتوي على 78 رسم توضيحي لكل كلمة موجودة بالملزمة (لكل كلمة !!!!)
#فهم_ماكو_درخ
3- دقة الكتابة والصور عالية جداً جداً جداً
4- هُنالك بعض المعلومات تم توضيحها بشكل تفصيلي جداً (تُعتبر لدى الطالب أو الطالبة بإنها معلومات مُبهمة ومع ذلك تم توضيح هذهِ المعلومات المُبهمة بشكل تفصيلي جداً
5- الملزمة تشرح نفسها ب نفسها بس تكلك تعال اقراني
6- تحتوي الملزمة في اول سلايد على خارطة تتضمن جميع تفرُعات معلومات الجهاز الهيكلي المذكورة في هذهِ الملزمة
واخيراً هذهِ الملزمة حلالٌ عليكم وإتمنى منكم إن تدعولي بالخير والصحة والعافية فقط
كل التوفيق زملائي وزميلاتي ، زميلكم محمد الذهبي 💊💊
🔥🔥🔥🔥🔥🔥🔥🔥🔥
Chapter wise All Notes of First year Basic Civil Engineering.pptxDenish Jangid
Chapter wise All Notes of First year Basic Civil Engineering
Syllabus
Chapter-1
Introduction to objective, scope and outcome the subject
Chapter 2
Introduction: Scope and Specialization of Civil Engineering, Role of civil Engineer in Society, Impact of infrastructural development on economy of country.
Chapter 3
Surveying: Object Principles & Types of Surveying; Site Plans, Plans & Maps; Scales & Unit of different Measurements.
Linear Measurements: Instruments used. Linear Measurement by Tape, Ranging out Survey Lines and overcoming Obstructions; Measurements on sloping ground; Tape corrections, conventional symbols. Angular Measurements: Instruments used; Introduction to Compass Surveying, Bearings and Longitude & Latitude of a Line, Introduction to total station.
Levelling: Instrument used Object of levelling, Methods of levelling in brief, and Contour maps.
Chapter 4
Buildings: Selection of site for Buildings, Layout of Building Plan, Types of buildings, Plinth area, carpet area, floor space index, Introduction to building byelaws, concept of sun light & ventilation. Components of Buildings & their functions, Basic concept of R.C.C., Introduction to types of foundation
Chapter 5
Transportation: Introduction to Transportation Engineering; Traffic and Road Safety: Types and Characteristics of Various Modes of Transportation; Various Road Traffic Signs, Causes of Accidents and Road Safety Measures.
Chapter 6
Environmental Engineering: Environmental Pollution, Environmental Acts and Regulations, Functional Concepts of Ecology, Basics of Species, Biodiversity, Ecosystem, Hydrological Cycle; Chemical Cycles: Carbon, Nitrogen & Phosphorus; Energy Flow in Ecosystems.
Water Pollution: Water Quality standards, Introduction to Treatment & Disposal of Waste Water. Reuse and Saving of Water, Rain Water Harvesting. Solid Waste Management: Classification of Solid Waste, Collection, Transportation and Disposal of Solid. Recycling of Solid Waste: Energy Recovery, Sanitary Landfill, On-Site Sanitation. Air & Noise Pollution: Primary and Secondary air pollutants, Harmful effects of Air Pollution, Control of Air Pollution. . Noise Pollution Harmful Effects of noise pollution, control of noise pollution, Global warming & Climate Change, Ozone depletion, Greenhouse effect
Text Books:
1. Palancharmy, Basic Civil Engineering, McGraw Hill publishers.
2. Satheesh Gopi, Basic Civil Engineering, Pearson Publishers.
3. Ketki Rangwala Dalal, Essentials of Civil Engineering, Charotar Publishing House.
4. BCP, Surveying volume 1
A Visual Guide to 1 Samuel | A Tale of Two HeartsSteve Thomason
These slides walk through the story of 1 Samuel. Samuel is the last judge of Israel. The people reject God and want a king. Saul is anointed as the first king, but he is not a good king. David, the shepherd boy is anointed and Saul is envious of him. David shows honor while Saul continues to self destruct.
5. The Java API
• A set of runtime libraries
• Available on any JVM
• Provide platform-independent standard
• Classes and interfaces
• Security
• Platform independence difficulties
• Implementation is specific to the host
platform
6. What is Java API
Documentation?
• Java documentation is HTML based
• Also called "Java Platform Standard Edition
API Specification"
• Complete documentation of all standard
classes and methods
• Descriptions of all the functionality
• Links to related articles
• Use local copy or the Web version from
http://java.sun.com/javase/6/docs/api/
10. Writing Java Programs
• Write custom source code
• In the Java programming language
• Using the Java API
• Compile the source code
• Using the “javac” compiler command
• Compiles to bytecodes
• Run the compiled code
• Using the “java” launcher command
11. Java Program – Example
HelloJava.java
public class HelloJava {
public static void main(String[] args) {
System.out.println("Hello, Java!");
}
}
javac HelloJava.java
java –cp . HelloJava
Hello, Java!
12. Typical Errors
• Compile-Time Errors
• javac: Command not found
• HelloJava.java:10: Method
printl(java.lang.String) not found in class
java.io.PrintStream
• HelloJava.java:4: Public class HelloJava
must be defined in a file called
"HelloJava.java".
13. Typical Errors
• Runtime Errors
• Can‟t find class HelloJava
• Exception in thread "main"
java.lang.NoClassDefFoundError:
HelloJava/class
15. The Source File Contents
• Java source code files can have three "toplevel" elements:
• An optional package declaration
• Any number of import statements
• Class and interface declarations
package jeecourse.example;
import java.io.*;
public class SomeClass {
// ...
}
16. Classes and Packages
• Classes are the main program unit in Java
• Contain the source code of the program
logic
• Can define fields
• Can contain methods (subprograms)
• Packages are containers for classes
• Can be nested hierarchically
• Each package can contain multiple classes
17. Important Java Packages
• Important packages within the Java class
library are:
• java.lang
• java.util
• java.io
• java.text
• java.awt
• java.net
• java.applet
18. Java Programs
• Java programs are sets of class definitions
• The main() method is the entry point for
standalone Java applications
• The signature for main() is:
public static void main(String[] args)
• The name args is purely arbitrary:
• Any legal identifier may be used, provided the
array is a single-dimension array of String
objects
19. Programs, Classes, and
Packages – Example
package jeecourse.example;
import java.io.*;
public class SomeClass {
private static int mValue = 5;
public static void printValue() {
System.out.println("mValue = " + mValue);
}
public static void main(String[] args) {
System.out.println("Some Class");
printValue();
}
}
21. Keywords
• A keyword is a word whose meaning is
defined by the programming language
• Anyone who claims to be competent in a
language must at the very least be familiar
with that language‟s keywords
• Java‟s keywords and other special-meaning
words are listed in the next slide
23. Reserved Words
• You may notice null, true, and false do
not appear anywhere on the keywords list
• true, false, and null are not keywords
but they are reserved words
• You cannot use them as names in your
programs either
24. Identifiers
• Names given to a variable, method, field,
class, interface, etc.
• Can start with a letter, underscore(_), or dollar
sign($)
• Can contain letters, $, _, and digits
• Case sensitive
• Have no maximum length
• Examples:
• userName, $app_name, __test, value,
totalRevenue, location$
25. Primitive Data Types
• A primitive is a simple non-object data type
that represents a single value
• Java‟s primitive data types are:
• boolean
• char
• byte, short, int, long
• float, double
26. Primitive Data Types
Type
Effective Size (bits)
byte
8
short
16
int
32
long
64
float
32
double
64
char
16
• Variables of type
boolean may take
only the values true
or false
• Their representation
size might vary
27. Boolean Type
• The boolean data type has two literals, true
and false
• For example, the statement:
• boolean truth = true;
• declares the variable truth as boolean type
and assigns it a value of true
28. Textual Types: char
• Represents a 16-bit Unicode character
• Must have its literal enclosed in single
quotes(‟ ‟)
• Uses the following notations:
•
•
•
•
'a' – The letter a
't' – A tab
'n' – A new line character
'u????' – A specific Unicode character,
????, is replaced with exactly four
hexadecimal digits, e.g. 'u1A4F'
29. Integral Types: byte,
short, int, and long
• Uses three forms – decimal, octal, or
hexadecimal, e. g.
• 2 – The decimal value is two
• 077 – The leading zero indicates an octal
value
• 0xBAAC – The leading 0x indicates a
hexadecimal value
• The default integer values are int
• Defines long by using the letter L or l:
long value = 1234L;
30. Ranges of the Integral
Primitive Types
Type
Size
Minimum
Maximum
byte
8 bits
-27
27 – 1
short
16 bits
-215
215 – 1
int
32 bits
-231
231 – 1
long
64 bits
-263
263 – 1
31. Floating Point Types: float
and double
• Default is double
• Floating point literal includes either a decimal
point or one of the following:
• E or e (add exponential value)
• F or f (float)
• D or d (double)
• Examples:
•
•
•
•
3.14 – A simple floating-point value (a double)
6.02E23 – A large floating-point value
2.718F – A simple float size value
123.4E+306D – A large double value with
redundant D
32. Ranges of the FloatingPoint Primitive Types
Type
Size
Minimum
Maximum
float
32 bits
+/- 1.40-45
+/- 3.40+38
double
64 bits
+/- 4.94-324
+/- 1.79+308
char
16 bits
0
216 - 1
34. Textual Types: String
• Is not a primitive data type
• It is a class
• Has its literal enclosed in double quotes (" ")
• Example:
"The quick brown fox jumps over the lazy dog."
• Can be used as follows:
String greeting = "Good Morning !! n";
String errorMsg = "Record Not Found!";
35. Values and Objects
• Primitive Data Types
• Are value types
• Contain directly their values
• Examples: int, float, char, boolean
• Objects
• Are reference types
• Contain a pointer (memory address) of their
values
• Examples: String, Object, Date
36. Values vs. Objects
• Consider the following code fragment:
int x = 7;
int y = x;
String s = "Hello";
String t = s;
• Two variables refer to a single object:
x
y
s
t
7
7
0x01234567
0x01234567
Heap (dynamic memory)
"Hello" 0x01234567
37. Enumerations (enums)
• Enumerations are special types that
• Get values from a given set of constants
• Are strongly typed
• Compiled to classes that inherit
java.lang.Enum
public enum Color {
WHITE, RED, GREEN, BLUE, BLACK
}
...
Color c = Color.RED;
38. Enumerations (enums)
• Allow using if and switch:
switch (color) {
case WHITE:
System.out.println("бяло");
break;
case RED:
System.out.println("червено");
break;
...
}
if (color == Color.RED) {
...
}
40. Variables, Declarations, and
Assignments
• Variables are names places in the memory
that contain some value
• Variables have a type (int, float, String, ...)
• Variables should be declared before use
• Variables can be assigned
• Examples:
int i; // declare variable
int value = 5; // declare and assign variable
i = 25; // assign a value to a variable that is
already declared
41. Variables, Declarations, and
Assignments – Examples
public class Assignments {
public static void main(String args []) {
int x, y; // declare int variables
float z = 3.414f; // declare and assign float
double w = 3.1415; // declare and assign double
boolean b = true; // declare and assign boolean
char ch; // declare character variable
String str; // declare String variable
String s = "bye"; // declare and assign String
ch = 'A'; // assign a value to char variable
str = "Hi out there!"; // assign value to String
x = 6; // assign value to int variable
y = 1000; // assign values to int variable
...
}
}
42. Variables and Scope
• Local variables are:
• Variables that are defined inside a method
and are called local, automatic, temporary,
or stack variables
• Created when the method is executed and
destroyed when the method is exited
• Variables that must be initialized before they
are used or compile-time errors will occur
44. The Ordinal Comparisons
Operators: <, <=, >, and >=
• The ordinal comparison operators are:
• Less than: <
• Less than or equal to: <=
• Greater than: >
• Greater than or equal to: >=
45. The Ordinal Comparisons
Operators – Example
• int p = 9;
• p < q true
• int q = 65;
• f < q true
• int r = -12;
• f <= c true
• float f = 9.0F;
• c > r true
• char c = „A‟;
• c >= q true
46. Short-Circuit Logical
Operators
• The operators are && (AND) and || (OR)
• These operators can be used as follows:
MyDate d = null;
if ((d != null) && (d.day() > 31)) {
// Do something
}
boolean goodDay = (d == null) || ((d != null) &&
(d.day() >= 12));
47. String Concatenation with +
• The + operator:
• Performs String concatenation
• Produces a new String as a result:
String salutation = "Dr. ";
String name = "Pete " + "Seymour";
System.out.println(salutation + name + 5);
• First argument must be a String object
• Non-strings are converted to String objects
automatically
48. The Unary Operators
• Unary operators take only a single operand
and work just on that
• Java provides seven unary operators:
• The increment and decrement operators: ++
and -• The unary plus and minus operators: + and • The bitwise inversion operator: ~
• The boolean complement operator: !
• The cast operator: ()
49. The Cast Operator: (type)
• Implicit type conversions are possible when
no information can be lost
• E.g. converting int long
• Casting is used for explicit conversion of the
type of an expression
• Casts can be applied to change the type of
primitive values
• For example, forcing a double value into an
int variable like this:
int circum = (int)(Math.PI * diameter);
50. The Multiplication and
Division Operators: * and /
• The * and / operators perform multiplication
and division on all primitive numeric types
and char
• Integer division will generate an
ArithmeticException when attempting to
divide by zero
int a = 5;
int value = a * 10;
51. The Bitwise Operators
• The bitwise operators: &, ^, and | provide
bitwise AND, eXclusive-OR (XOR), and OR
operations, respectively
• They are applicable to integral types
int first = 100;
int second = 200;
int xor = first ^ second;
int and = first & second;
52. Operator Evaluation Order
• In Java, the order of evaluation of operands in
an expression is fixed – left to right
• Consider this code fragment:
int[] a = {4, 4};
int b = 1;
a[b] = b = 0;
• In this case, it might be unclear which element
of the array is modified:
• Which value of b is used to select the array
element, 0 or 1
54. Expressions
• Expression is a sequence of operators,
variables and literals that is evaluated to
some value
int r = (150-20) / 2 + 5;
// Expression for calculation of
// the surface of the circle
double surface = Math.PI * r * r;
// Expression for calculation of
// the perimeter of the circle
double perimeter = 2 * Math.PI * r;
55. Statements
• Statements are the main programming
constructs
• Types of statements
• Simple statements
• The smallest programming instructions
• Block statements – { ... }
• Conditional statements (if, if-else,
switch)
• Loop statements (for, while, do/while)
56. Statements and Blocks
• A statement is a single line of code
terminated by a semicolon(;)
salary = days * daySalary;
• A block is a collection of statements
bounded by opening and closing braces:
{
x = x + 1;
y = y + 1;
}
• You can nest block statements
57. Conditional Statements
• The if, if-else statements:
if (boolean condition) {
statement or block;
}
if (boolean condition) {
statement or block;
} else {
statement or block;
}
58. If Statement – Example
public static void main(String[] args) {
int radius = 5;
double surface = Math.PI * radius * radius;
if (surface > 100) {
System.out.println("The circle is too big!");
} else if (surface > 50) {
System.out.println(
"The circle has acceptable size!");
} else {
System.out.println(
"The circle is too small!");
}
}
59. Conditional Statements
• The switch statement
switch (expression) {
case constant1:
statements;
break;
case constant2:
statements;
break;
default:
statements;
break;
}
60. The switch Statement –
Example
int dayOfWeek = 3;
switch (dayOfWeek) {
case 1:
System.out.println("Monday");
break;
case 2:
System.out.println("Tuesday");
break;
...
default:
System.out.println("Invalid day!");
break;
}
61. Looping Statements
• The for statement:
for (init_expr; boolean testexpr; alter_expr) {
statement or block;
}
• Example:
for (int i = 0; i < 10; i++) {
System.out.println("i=" + i);
}
System.out.println("Finished!")
62. Looping Statements
• The enhanced for statement:
for (Type variable : some collection) {
statement or block;
}
• Example:
public static void main(String[] args) {
String[] towns = new String[] {
"Sofia", "Plovdiv", "Varna" };
for (String town : towns) {
System.out.println(town);
}
}
63. Looping Statements
• The while loop:
while (boolean condition) {
statement or block;
}
• Examples:
int i=100;
while (i>0) {
System.out.println("i=" + i);
i--;
}
while (true) {
// This is an infinite loop
}
64. Looping Statements
• The do/while loop:
do {
statement or block;
} while (boolean condition);
• Example:
public static void main(String[] args) {
int counter=100;
do {
System.out.println("counter=" + counter);
counter = counter - 5;
} while (counter>=0);
}
65. Special Loop Flow Control
• Some special operators valid in loops:
• break [label];
• continue [label];
• label: statement; // Where statement
should be a loop
• Example (breaking a loop):
for (int counter=100; counter>=0; counter-=5) {
System.out.println("counter=" + counter);
if (counter == 50)
break;
}
66. Special Loop Flow Control –
Examples
• Example (continuing a loop):
for (int counter=100; counter>=0; counter-=5) {
if (counter == 50) {
continue;
}
System.out.println("counter=" + counter);
}
67. Special Loop Flow Control –
Examples
• Example (breaking a loop with a label):
outerLoop:
for (int i=0; i<50; i++) {
for (int counter=100; counter>=0; counter-=5) {
System.out.println("counter=" + counter);
if ((i==2) && (counter == 50)) {
break outerLoop;
}
}
}
68. Comments
• Three permissible styles of comment in a
Java technology program are:
// comment on one line
/* comment on one
or more lines */
/** documenting comment */
70. Console Input/Output
• The input/output from the console is done
through 3 standard streams
• System.in – the standard input
• System.out – the standard output
• System.err – the standard error output
• To facilitate some operations additional
classes should be involved
• Scanner
• BufferedReader, InputStreamReader
71. Printing to the Console
• System.out.print(...)
• Can take as input different types
• String, int, float, Object, ...
• Non-string types are converted to String
• System.out.println(...)
• Like print(...) but moves to the next line
System.out.print(3.14159);
System.out.println("Welcome to Java");
int i=5;
System.out.println("i=" + i);
72. Reading from the Console
• First construct a Scanner that is attached to
the “standard input stream” System.in
Scanner in = new Scanner(System.in);
• Then use various methods of the Scanner
class to read input
• nextLine() String
• Reads a line of input
• next() String
• Reads a single word delimited by whitespace
73. Reading from the Console
• Scanner – more methods
• nextInt() int
• Reads an int value. Throws
InputMismatchException on error
• nextLong() long
• nextFloat() float
• Reads a float value. Throws
InputMismatchException on error
• nextDouble() double
74. Scanner – Example
import java.util.Scanner;
public class ScannerDemo {
public static void main(String[] args) {
Scanner console = new Scanner(System.in);
// Get the first input
System.out.print("What is your name? ");
String name = console.nextLine();
// Get the second input
System.out.print("How old are you? ");
int age = console.nextInt();
}
}
// Display output on the console
System.out.println("Hello, " + name + ". " +
"Next year, you'll be " + (age + 1));
75. Formatting Output
• System.out.printf(<format>, <values>)
• Like the printf function in C language
String name = "Nakov";
int age = 25;
System.out.printf(
"My name is %s.nI am %d years old.",
name, age);
• Some formatting patterns
• %s – Display as string
%f – Display as float
• %d – Display as number
%t – Display as date
* For more details see java.util.Formatter
77. Creating Arrays
• To create and use an array, follow three
steps:
1. Declaration
2. Construction
3. Initialization
4. Access to Elements
78. Array Declaration
• Declaration tells the compiler the array‟s
name and what type its elements will be
• For example:
int[] ints;
Dimensions[] dims;
float[][] twoDimensions;
• The square brackets can come before or
after the array variable name:
int ints[];
79. Array Construction
• The declaration does not specify the size of
an array
• Size is specified at runtime, when the array
is allocated via the new keyword
• For example:
int[] ints; // Declaration
ints = new int[25]; // Construction
• Declaration and construction may be
performed in a single line:
int[] ints = new int[25];
80. Array Initialization
• When an array is constructed, its elements
are automatically initialized to their default
values
• These defaults are the same as for object
member variables
• Numerical elements are initialized to 0
• Non-numeric elements are initialized to 0like values, as shown in the next slide
82. Array Elements Initialization
• Initial values for the elements can be
specified at the time of declaration and
initialization:
float[] diameters =
{1.1f, 2.2f, 3.3f, 4.4f, 5.5f};
• The array size is inferred from the number
of elements within the curly braces
83. Access to Elements
• Accessing array elements:
int[] arr = new int[10];
arr[3] = 5; // Writing element
int value = arr[3]; // Reading element
• Elements access is range checked
int[] arr = new int[10];
int value = arr[10];
// ArrayIndexOutOfBoundsException
• Arrays has field length that contains their
number of elements
84. Arrays – Example
// Finding the smallest and largest
// elements in an array
int[] values = {3,2,4,5,6,12,4,5,7};
int min = values[0];
int max = values[0];
for (int i=1; i<values.length; i++) {
if (values[i] < min) {
min = values[i];
} else if (values[i] > max) {
max = values[i];
}
}
System.out.printf("MIN=%dn", min);
System.out.printf("MAX=%dn", max);
85. Multi-dimensional Arrays
• Multidimensional arrays in Java are actually
arrays of arrays
• Defining matrix:
int[][] matrix = new int[3][4];
• Accessing matrix elements:
matrix[1][3] = 42;
• Getting the number of rows/columns:
int rows = matrix.length;
int colsInFirstRow = matrix[0].length;
86. Multi-dimensional Arrays
• Consider this declaration plus initialization:
int[][] myInts = new int[3][4];
• It‟s natural to assume that the myInts
contains 12 ints and to imagine them as
organized into rows and columns, as shown:
WRONG!
88. Multi-dimensional Arrays
• The subordinate
arrays in a multidimension array don‟t
have to all be the
same length
• Such an array may be
created like this:
int[][] myInts = { {1, 2, 3},
{91, 92, 93, 94},
{2001, 2002} };
89. Multi-dimensional Arrays –
Example
// Finding the sum of all positive
// cells from the matrix
int[][] matrix =
{{2,4,-3},
{8,-1,6}};
int sum = 0;
for (int row=0; row<matrix.length; row++) {
for (int col=0; col<matrix[row].length;
col++) {
if (matrix[row][col] > 0) {
sum += matrix[row][col];
}
}
}
System.out.println("Sum = " + sum);
91. Exercises
1. Write an expression that checks if given integer
is odd or even.
2. Write a boolean expression that for given
integer checks if it can be divided (without
remainder) by 7 and 5.
3. Write an expression that checks if a given
integer has 7 for its third digit (right-to-left).
4. Write a boolean expression for finding if the bit
3 of a given integer is 1 or 0.
5. Write a program that for a given width and
height of a rectangle, outputs the values of the
its surface and perimeter.
92. Exercises
6. Write a program that asks the user for a fourdigit number abcd and:
1.
2.
3.
4.
Calculates the sum of its digits
Prints its digits in reverse order: dcba
Puts the last digit in at the front: dabc
Changes the position of the second and third
digits: acbd
7. Write an expression that checks if a given
number n (n ≤ 100) is a prime number.
8. Write a boolean expression that returns true if
the bit at position p in a given integer v is 1.
Example: if v=5 and p=1, return false.
93. Exercises
9. Write a program that reads 3 integer numbers
from the console and prints their sum.
10.Write a program that reads the radius r of a
circle and prints its perimeter and area.
11.A company has name, address, phone number,
fax number, Web site and manager. The
manager has first name, last name and a phone
number. Write a program that reads the
information about a company and its manager
and prints it on the console.
94. Exercises
12.Write a program that reads from the console
two integer numbers and prints how many
numbers exist between them, such that the
reminder of the division by 5 is 0.
13.Write a program that gets two numbers from
the console and prints the greater of them.
Don‟t use if statements.
14.Write a program that reads 5 numbers and
prints the greatest of them.
15.Write a program that reads 5 numbers and
prints their sum.
95. Exercises
16.Write an if statement that examines two
integer variables and exchanges their values if
the first one is greater than the second one.
17.Write a program that shows the sign (+ or -) of
the product of three real numbers without
calculating it. Use sequence of if statements.
18.Write a program that finds the biggest of three
integers using nested if statements.
19.Write a program that sorts 3 real values in
descending order using nested if statements.
96. Exercises
20.Write program that for a given digit (0-9)
entered as input prints the name of that digit (in
Bulgarian). Use a switch statement.