Professional Documents
Culture Documents
Copyright Guideline
2013 Infosys Limited, Bangalore, India. All Rights Reserved.
Infosys believes the information in this document is accurate as of its publication date; such
information is subject to change without notice. Infosys acknowledges the proprietary rights of
other companies to the trademarks, product names and such other intellectual property rights
mentioned in this document. Except as expressly permitted, neither this documentation nor
any part of it may be reproduced, stored in a retrieval system, or transmitted in any form or by
any means, electronic, mechanical, printing, photocopying, recording or otherwise, without the
prior permission of Infosys Limited and/ or any named intellectual property rights holders
under this document.
Confidential
Confidential Information
This Document is confidential to Infosys Limited. This document contains information and data that
Infosys considers confidential and proprietary (Confidential Information).
Confidential Information includes, but is not limited to, the following:
Corporate and Infrastructure information about Infosys
Infosys project management and quality processes
Project experiences provided included as illustrative case studies
Any disclosure of Confidential Information to, or use of it by a third party, will be damaging to Infosys.
Ownership of all Infosys Confidential Information, no matter in what media it resides, remains with
Infosys.
Confidential information in this document shall not be disclosed, duplicated or used in whole or in part
for any purpose other than reading without specific written permission of an authorized representative of
Infosys.
This document also contains third party confidential and proprietary information. Such third party
information has been included by Infosys after receiving due written permissions and authorizations from
the party/ies. Such third party confidential and proprietary information shall not be disclosed, duplicated
or used in whole or in part for any purpose other than reading without specific written permission of
an authorized representative of Infosys.
3
Copyright 2013-2014,
Infosys Limited
Confidential
Course Information
Confidential
Recap
Object Oriented Fundamentals
Java Architecture
Variables in detail
Reference Variables & Objects in Memory
Methods Parameter Passing Techniques
this reference
Data Structures
Linear
Nonlinear
Confidential
OO Fundamentals
OO Fundamentals
Object Oriented Fundamentals
Arrays Revisit
Strings
Constructors
static keyword
Command Line Arguments
Confidential
Arrays - Revisit
Arrays (1 of 4)
An array is a collection of similar data in contiguous locations of memory having
the same name
Arrays can be used to store data belonging to primitive data types and reference
types
Types of Arrays
Single Dimensional Arrays
Multi-Dimensional Arrays
Copyright
2013-2014, Infosys Limited
Confidential
10
Arrays (2 of 4)
Single Dimensional Arrays :
An array with one dimension (one row) is called a single dimensional array
Different ways of creating and initializing an array are given below
Method 1:
Method 2:
long [] telephoneNos= {48214280200L, 9901911334L, 4821710601L};
Confidential
11
Arrays (3 of 4)
long[]
4821428020
telephoneNos
9901911334
4821710601
Stack
Heap
Confidential
12
Arrays (4 of 4)
Quiz: OO Fundamentals Assignment 47
Length property
Length property represents the size of an array
Length of an array can be identified using the below statement
arrayname.length
Confidential
Strings
14
Strings (1 of 3)
Guided Activity: OO Fundamentals - Assignment 49
Confidential
Wherewillthe
memorybe
allocated?
15
Strings (2 of 3)
Jack
customerName
Stack
Heap
Confidential
16
Strings (3 of 3)
String class contains many methods which facilitate operations on the Strings
length()
concat()
equals()
equalsIgnoreCase() etc
Confidential
17
Strings - Revisit
Confidential
OO Constructs - I
Constructors
20
Constructor
Guided Activity: OO Fundamentals - Assignment 53
Constructor is a special method that has the same name as that of a class
The constructor is used to initialize the instance variables of the class
Types of constructors:
Default constructor
Demo: OO Fundamentals - Assignment 54
Parameterized constructor
Demo: OO Fundamentals - Assignment 55
Confidential
static keyword
22
static keyword (1 of 2)
Demo: OO Fundamentals - Assignment 56
The concept of static is used whenever data which is common to the objects of
the class is required
In Java, static keyword can be used in 3 scenarios:
static variables:
Also called class variables and are initialized at class load time
static methods
Used for accessing static variables.
Can be invoked using class name or object reference
static blocks
Block of statements in a java class which gets executed when a class is first loaded in memory
Can have any number of static blocks in which case it gets executed in the order in which it is
written
Confidential
23
static keyword (2 of 2)
Static methods and static blocks can access only other static data members and
methods directly
Non static variable cannot be accessed directly inside a static method or static
block
Confidential
25
Confidential
26
Confidential
27
Arrays
Strings
Constructors
static keyword
Command Line Arguments
Confidential
29
Confidential
30
are
Greedy Approach
First solve the problem that requires least effort
Confidential
31
Confidential
32
Confidential
33
Confidential
34
Confidential
35
Confidential
36
Analysis: This just has a linear loop with array accesses in the loop, so this has a
complexity of O(n)
Confidential
3737
Greedy approach
Primarily used in Optimization problems
Constructs solution through a sequence of steps where each step is considered
to be a partial solution. This is extended to get the complete solution
Choice of each step must be
Locally optimal
Feasible
Irrevocable
Confidential
Thank You
2013 Infosys Limited, Bangalore, India. All Rights Reserved. Infosys believes the information in this document is accurate as of its publication date; such information is subject to change
without notice. Infosys acknowledges the proprietary rights of other companies to the trademarks, product names and such other intellectual property rights mentioned in this document. Except
as expressly permitted, neither this documentation nor any part of it may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, electronic, mechanical, printing,
photocopying, recording or otherwise, without the prior permission of Infosys Limited and/ or any named intellectual property rights holders under this document.
Appendix
40
Method 1
int array[][]= new int[2][3]; or int[][] array= new int [2][3];
array[0][0]=1;
array[0][1]=2; etc
Method 2
Confidential
41
arrayname[rownumber].length
arrNum.length, i.e 2
arrNum[1].length, i.e 2
Confidential
42
Greedy approach
Primarily used in Optimization problems
Constructs solution through a sequence of steps where each step is considered
to be a partial solution. This is extended to get the complete solution
Choice of each step must be
Locally optimal
Feasible
Irrevocable
Confidential