Seminar Report - Nothing PDF

Title Seminar Report - Nothing
Author Nandini Jha
Course Software Engineering
Institution University of Lucknow
Pages 29
File Size 684.1 KB
File Type PDF
Total Downloads 21
Total Views 705

Summary

A Seminar on LatestProgramming LanguageFor Android Development (Kotlin)Presented ByMohammad Jeeshan(University Roll no. 1709510023)Under the guidance ofProfessor Mohd. AsimMGM’s College of EngineeringAnd Technology, NoidaDEPARTMENT OF COMPUTER SCIENCE & ENGINEERINGMGM’s College of Engineering &a...


Description

A Seminar on Latest Programming Language For Android Development (Kotlin) Presented By Mohammad Jeeshan (University Roll no. 1709510023) Under the guidance of Professor Mohd. Asim MGM’s College of Engineering And Technology, Noida

DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING MGM’s College of Engineering & Technology, Noida June, 2021

1|Page

ACKNOWLEDGEMENT It gives me a great sense of pleasure to present the report of the B. Tech seminar undertaken during B. Tech final year. I owe special debt of gratitude to Mr. Mohd Asim Assistant Professor in the Department of Computer Science & Engineering, MGM College of Engineering and Technology, Noida for his constant support and guidance throughout the course of my work. His sincerity, thoroughness and perseverance have been a constant source of inspiration for me. It is only his cognizant efforts that my endeavours have seen light of the day. I also take the opportunity to acknowledge the contribution of Mrs. Archana Sar Head of Department of Computer Science & Engineering, MGM College of Engineering and Technology, Noida for her full support and assistance during the preparation of the seminar. I also do not like to miss the opportunity to acknowledge the contribution of all faculty members of the department for their kind assistance and cooperation.

Signature of student Name: Mohammad Jeeshan Roll No. : 1709510023 Date: 24-June-2021

2|Page

CERTIFICATES This is to certify that seminar report entitled “E-Post Office” which is submitted by S.K.Mourya in partial fulfilment of the requirement for the award of degree B.Tech in Department of Computer Science & Engineering of Dr. A.P.J. Abdul Kalam Technical University. It is a record of the candidate own work carried out by him under my supervision. The matter embodied in this report is original and has not been submitted by other,

Date:

Supervisor name with signature

3|Page

Table of Contents 1. Acknowledgement...…………………………………………………………………………… 2. Certificates…………………………………………………………………………………………. 3. Introduction……………………………………………………………………………………….. 4. Basics of Kotlin…………………………………………………………………………………..  What is Kotlin..............................................................................  History of Kotlin…………………………………………………………………………  Kotlin Variable……………………………………………………………………………  Kotlin Data Type…………..……………………………………………………………  Kotlin Type Conversion………………………………………………………………  Kotlin Operator ………………………………………………………………………….  Kotlin Input/output……………………………………………………………………  Kotlin Comment………………………………………………………………………… 5. Functions in Kotlin………………………………………………………………………………  Kotlin Function…………………………………………………………………………..  Recursion Function…………………………………………………………………….  Default and Named Argument…………………………………………………..  Kotlin Lambdas Function……………………………………………………………  Higher order Function……………………………………………………………….  Kotlin Inline Function………………………………………………………………… 6. Control Flow in Kotlin………………………………………………………………………….  Kotlin if – else Statement…………………………………………………………..  Kotlin when Expression……………………………………………………………..  Kotlin for Loop………………………………………………………………………….. 4|Page

 Kotlin while Loop……………………………………………………………………….  Kotlin Do while Loop………………………………………………………………….  Return and Jump……………………………………………………………………….  Continue ………………………………………………………………………………….. 7. Exception Handling in Kotlin……………………………………………………………….  Exception Handling……………………………………………………………………  Kotlin Try Catch………………………………………………………………………….  Multiple Catch Block………………………………………………………………….  Finally Block………………………………………………………………………………. 8. Collection in Kotlin……………………………..……………………………………………….  Kotlin Array……………………………………………………………………………….  Kotlin String………………………………………………………………………………  Kotlin List………………………………………………………………………………….  Kotlin Hash Map………………………………………………………………………..  Kotlin Set………………………………………………………………………………….. 9. Kotlin OPPs concept………….……………………………………………………………….  Class and Object………………………………………………………………………..  Nested and Inner Class………………………………………………………………  Kotlin Constructor ……………………………………………………………………..  Visibility Modifier………………………………………………………………………  Kotlin Inheritance………………………………………………………………………  Abstract Class…………………………………………………………………………….  Kotlin Interface………………………………………………………………………….  Data Class.………………………………………………………………………………… 10. Kotlin Nullability.……………….………………………………………………………………. 5|Page

11. Conclusion………………………………………………………………………………………….. 12. References………………………………………………………………………………………….

6|Page

3. INTRODUCTION The Kotlin programming language is a modern language that gives you more power for your everyday tasks. Kotlin is concise, safe, pragmatic, and focused on interoperability with Java code. It can be used almost everywhere Java is used today: for server-side development, Android apps, and much more. Kotlin is 100% compatible with all existing Java frameworks, and has good tooling support. It’s a pragmatic language with a very low learning curve, and can be quickly grasped by Java developers. Kotlin code might be compiled not only to JVM bytecode but to JavaScript and Native code as well, but this course is focused on Kotlin/JVM.

This course aims to share with you the power and the beauty of Kotlin. We'll have a basic overview of the language, as well as a discussion of many corner cases, especially concerning Java interoperability. The course is based on your Java experience; it shows the similarities between the two languages and focuses on what's going to be different. Note that this course won't cover the programming fundamentals. We'll discuss: basic syntax, nullability, functional programming with Kotlin, object-oriented programming with Kotlin, the power of the Kotlin standard library, and Java interoperability.

7|Page

4. Basics Of Kotlin What is Kotlin Kotlin is a general-purpose, statically typed, and open-source programming language. It runs on JVM and can be used anywhere Java is used today. It can be used to develop Android apps, serverside apps and much more.

History of Kotlin Kotlin was developed by JetBrains team. A project was started in 2010 to develop the language and officially, first released in February 2016. Kotlin was developed under the Apache 2.0 license.

Kotlin Variable Variable refers to a memory location. It is used to store data. The data of variable can be changed and reused depending on condition or on information passed to the program.

Kotlin Data Type Data type (basic type) refers to type and size of data associated with variables and functions. Data type is used for declaration of memory location of variable which determines the features of data. In Kotlin, everything is an object, which means we can call member function and properties on any variable. There are different types ->  Number  Character 8|Page

 Boolean  Array  String

Kotlin Type Conversion Type conversion is a process in which one data type variable is converted into another data type. In Kotlin, implicit conversion of smaller data type into larger data type is not supported (as it supports in java). For example Int cannot be assigned into Long or Double.

Kotlin Operator Operators are special characters which perform operation on operands (values or variable).There are various kind of operators available in Kotlin.  Arithmetic operator  Relation operator  Assignment operator  Unary operator  Bitwise operation  Logical operator

9|Page

Kotlin Standard Input/output Kotlin standard input output operations are performed to flow byte stream from input device (keyboard) to main memory and from main memory to output device (screen).

Kotlin Comment Comments are the statements that are used for documentation purpose. Comments are ignored by compiler so that don't execute. We can also use it for providing information about the line of code. There are two types of comments in Kotlin.  Single line comment.  Multi line comment.

10 | P a g e

5. Functions in Kotlin Kotlin Function Function is a group of inter related block of code which performs a specific task. Function is used to break a program into different sub module. It makes reusability of code and makes program more manageable. In Kotlin, functions are declared using fun keyword. There are two types of functions depending on whether it is available in standard library or defined by user.  Standard library function  User defined function

Kotlin Recursion Function When any function call it-self that type of functions are known as Recursion functions. There are two type of recursion function.  Tail recursion  Head recursion

Kotlin Default Argument Kotlin provides a facility to assign default argument (parameter) in a function definition. If a function is called without passing any argument than default argument are used as parameter of function definition. And when a function is called using argument, than the passing argument is used as parameter in function definition. 11 | P a g e

Kotlin Lambda Function Lambda is a function which has no name. Lambda is defined with a curly braces {} which takes variable as a parameter (if any) and body of function. The body of function is written after variable (if any) followed by -> operator.

Higher order function High order function (Higher level function) is a function which accepts function as a parameter or returns a function or can do both. Means, instead of passing Int, String, or other types as a parameter in a function we can pass a function as a parameter in other function.

Inline Function An inline function is declared with a keyword inline. The use of inline function enhances the performance of higher order function. The inline function tells the compiler to copy parameters and functions to the call site. The virtual function or local function cannot be declared as inline. Following are some expressions and declarations which are not supported anywhere inside the inline functions:  Declaration of local classes  Declaration of inner nested classes  Function expressions  Declarations of local function 12 | P a g e

6. Control Flow in Kotlin Kotlin if Expression In Kotlin, if is an expression is which returns a value. It is used for control the flow of program structure. There is various type of if expression in Kotlin.  if-else expression  if-else if-else ladder expression  nested if expression Syntax-> if(condation){ //code statement } else{ //code statement }

Kotlin when Expression Kotlin, when expression is a conditional expression which returns the value. Kotlin, when expression is replacement of switch statement. Kotlin, when expression works as a switch statement of other language (Java, C++, C). Syntax-> var number = 4 var numberProvided = when(number) { 13 | P a g e

1 -> "One" 2 -> "Two" 3 -> "Three" 4 -> "Four" else -> "invalid number" }

Kotlin for Loop Kotlin for loop is used to iterate a part of program several times. It iterates through arrays, ranges, collections, or anything that provides for iterate. Kotlin for loop is equivalent to the foreach loop in languages like C#. Syntax-> for (item in collection){ //body of loop }

Kotlin while Loop The while loop is used to iterate a part of program several time. Loop executed the block of code until the condition has true. Kotlin while loop is similar to Java while loop. Syntax while(condition){ //body of loop }

14 | P a g e

Kotlin do-while Loop The do-while loop is similar to while loop except one key difference. A do-while loop first execute the body of do block after that it check the condition of while. As a do block of do-while loop executed first before checking the condition, do-while loop execute at least once even the condition within while is false. The while statement of do-while loop end with (semicolon). Syntax do{ //body of do block } while(condition);

Kotlin Return and Jump There are three jump expressions in Kotlin. These jump expressions are used for control the flow of program execution. These jump structures are:  break  continue  return Break Expression A break expression is used for terminate the nearest enclosing loop. It is almost used with if-else condition. For example: for(..){ 15 | P a g e

//body of for if(checkCondition){ break; }

Kotlin continue Jump Structure Kotlin, continue statement is used to repeat the loop. It continues the current flow of the program and skips the remaining code at specified condition. The continue statement within a nested loop only affects the inner loop. For example for(..){ //body of for above if if(checkCondition){ continue } //body of for below if }

16 | P a g e

7. Kotlin Exception Handling

Exception is a runtime problem which occurs in the program and leads to program termination. This may be occure due to running out of memory space, array out of bond, condition like divided by zero. To handle this type of problem during program execution the technique of exception handling is used. Exception handling is a technique which handles the runtime problems and maintains the flow of program execution. In Kotlin, all exception classes are descendants of class Throwable. To throw an exception object, Kotlin uses the throw expression. throw MyException("this throws an exception") There are four different keywords used in exception handling. These are:  try  catch  finally  throw try: try block contains set of statements which might generate an exception. It must be followed by either catch or finally or both. catch: catch block is used to catch the exception thrown from try block. finally: finally block always execute whether exception is handled or not. So it is used to execute important code statement. 17 | P a g e

throw: throw keyword is used to throw an exception explicitly.

Kotlin Unchecked Exception Unchecked exception is that exception which is thrown due to mistakes

in

our

code.

This

exception

type

extends RuntimeException class. The Unchecked exception is checked at run time. Following are some example of unchecked exception:  ArithmeticException: thrown when we divide a number by zero.  ArrayIndexOutOfBoundExceptions: thrown when an array has been tried to access with incorrect index value.  SecurityException: thrown by the security manager to indicate a security violation.  NullPointerException: thrown when invoking a method or property on a null object.

18 | P a g e

8. Kotlin Collections Kotlin Collections Collections in Kotlin are used to store group of related objects in a single unit. By using collection, we can store, retrieve manipulate and aggregate data. Types of Kotlin Collections Kotlin collections are broadly categories into two different forms. These are:  Immutable Collection (or Collection)  Mutable Collection

Immutable Collection: Immutable collection also called Collection supports read only functionalities. Methods of immutable collection that supports read functionalities are:

Collection Types List

Methods of Immutable Collection

listOf() listOf()

Map

mapOf()

Set

setOf()

19 | P a g e

Mutable Collection: Mutable collections supports both read and write functionalities. Methods of mutable collections that supports read and write functionalities are: Collection Types List

Methods of Mutable Collection

ArrayList() arrayListOf() mutableListOf()

Map

HashMap hashMapOf() mutableMapOf()

Set

hashSetOf() mutableSetOf()

20 | P a g e

9. Kotlin OPP’s Concepts

Kotlin Class and Object Kotlin supports both object oriented programming (OOP) as well as functional programming. Object oriented programming is based on real time objects and classes. Kotlin also support pillars of OOP language such as encapsulation, inheritance and polymorphism. Kotlin Class Kotlin class is similar to Java class, a class is a blueprint for the objects which have common properties. Kotlin classes are declared using keyword class. Kotlin class has a class header which specifies its type parameters, constructor etc. and the class body which is surrounded by curly braces. Syntax of Kotlin class declaration class className{ // class header // property // member function }

Kotlin Object Object is real time entity or may be a logical entity which has state and behavior. It has the characteristics:  state: it represents value of an object.  behavior: it represent the functionality of an object. 21 | P a g e

Object is used to access the properties and member function of a class. Kotlin allows creating multiple object of a class.

Kotlin Nested class Nested class is such class which is created inside another class. In Kotlin, nested class is by default static, so its data member and member function can be accessed without creating an object of class. Nested class cannot be able to access the data member of outer class. class outerClass{ //outer class code class nestedClass{ //nested class code } }

Kotlin Inner class Inner class is a class which is created inside another class with keyword inner. In other words, we can say that a nested class which is marked as "inner" is called inner class. Inner class cannot be declared inside interfaces or non-inner nested classes. class outerClass{ //outer class code inner class innerClass{ //nested class code } 22 | P a g e

Kotlin Constructor In

Kotlin,

constructor

is

a

block

of

code

similar

to

method. Constructor is declared with the same name as the class followed by parenthesis '()'. Constructor is used to initialize the variables at the time of object creation. Types of Kotlin constructors There are two types of constructors in Kotlin:  Primary constructor  Secondary constructor There is only one primary constructor in a Kotlin class whereas secondary constructor may be one or more.

Kotlin primary constructor Primary constructor is used to initialize the class. It is declared at class header. Primary constructor code is surrounded by parentheses with optional parameter. Let's see an example of declaration of primary constructor. In the below code, we declare a constructor myClass with two parameter name and id. Parameter name is only read property whereas id is read and write property. class myClass(valname: String,varid: Int) { // class body }

Kotlin secondary constructor In Kotlin, secondary constructor can be created one or more in class. The secondary constructor is created using "constructor" keyword. 23 | P a g e

Let's see an example of declaration of secondary constructor. In the below code, we declare two constructor of myClass with two parameter name and id. class myClass{

constructor(id: Int){ //code } constructor(name: String, id: Int){ //code } }

Kotlin Visibility Modifier Visibility modifiers are the keywords which are used to restrict the use of class, interface, methods, and property of Kotlin in the application. These modifiers are used at multiple places such as class header or method body. In Kotlin, visibility modifiers are categorized into four different types:  public  protected  internal 

private

24 | P a g e

Kotlin Inheritance Inheritance is an important feature of object oriented programming language. Inheritance allows to inherit the feature of existing class (or base or parent class) to new class (or derived class or child class). The main class is called super class (or parent class) and the class which inherits the superclass is called subclass (or chil...


Similar Free PDFs