0% found this document useful (0 votes)
8 views11 pages

Venkatesh Maipathii

Uploaded by

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

Venkatesh Maipathii

Uploaded by

MONICA NAHAK
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

Dt : 21/9/2023

Summary : Object Oriented Programming features:

(a)Class

=>Class is a 'structured layout' generating Objects.

=>Based on Security:

ii
(i)Mutable Classes

ath
(ii)Immutable classes

(b)Object

aip
=>Object is a storage related to a class holding Instance members

of class.
hM
=>Based on Security,Objects are categorized into two types:

(i)Mutable Objects

(ii)Immutable Objects
tes

(c)Abstraction
a
nk

=>The process of hiding the background implementation which is not

needed by the EndUsers is known as 'Abstraction process'


Ve

=>we use "Interfaces" and "AbstractClasses" to perform abstraction

process.

(d)Encapsulation

=>The process of binding all the programming components into a single

unit class is known as "Encapsulation process".


=>Which means,Class is holding variables,methods,blocks,Constructors,

InnerClases,InnerInterfaces,InnerAbstractClasses and Exception

handling components like try,catch,finally,throw and throws.

(e)PolyMorphism

=>The process in which programming Components having more than one

ii
form is known as PolyMorphism.

ath
(i)Dynamic PolyMorphism

=>Method Overriding process

aip
(ii)Static PolyMorphism

=>Method Overloading process


hM
=>Objects will have two forms:

(i)Mutable Objects

(ii)Immutable Objects
tes

(f)Inheritance

=>The process of interlinking classes with "extends" keyword is


a
nk

known as Inheritance.

=>Types of Inheritances:
Ve

1.Single Inheritance

2.Multiple Inheritance

3.Multi-Level Inheritance

4.Hirarchal Inheritance

5.Hybrid Inheritance
=>According to realtime application development the Inheritances

are categorized into two types:

1.Single Inheritance

2.Multiple Inheritance(Using Interfaces)

===================================================================
=

ii
ath
*imp

Strings in Java:

=>The sequenced collection of characters which are represented in double

quotes is known as string.

Ex:
aip
hM
"nit","hyd",...

=>Each character in the string is organized based on index value.


tes

=>strings in java are not Arrays.

=>we use the following classes from java.lang package to create string
a

objects:
nk

1.String class
Ve

2.StringBuffer class

3.StringBuilder class

1.String class:

=>The Objects which are created using "java.lang.String" class are


Immutable Objects.

=>we use the following two syntaxes to creates String-class Objects:

syntax-1 : using "String Literal process"

String s1 = "nit";

syntax-2 : using "new operator process"

ii
String s2 = new String("program");

ath
Diagrams:

aip
hM
a tes
nk
Ve

Ex : DemoString1.java
package maccess;
public class DemoString1 {
public static void main(String[] args) {
String s1 = "nit";
int len1 = s1.length();
char ch1 = s1.charAt(1);
System.out.println("****s1****");
System.out.println("s1 : "+s1.toString());
System.out.println("length of s1 : "+len1);
System.out.println("char at index 1 : "+ch1);
String s2 = new String("program");

ii
int len2 = s2.length();

ath
char ch2 = s2.charAt(3);
System.out.println("****s2****");
System.out.println("s2 : "+s2.toString());
System.out.println("length of s2 : "+len2);

aip
System.out.println("char at index 3 : "+ch2);
}
}
hM
o/p:

****s1****
tes

s1 : nit

length of s1 : 3
a

char at index 1 : i
nk

****s2****
Ve

s2 : program

length of s2 : 7

char at index 3 : g

==============================================================

faq:
define toString() method?

=>toString() method is used to display the content(data) from the Object.

=>toString() method is auto-executable method and which is executed

automatically when we display object reference variable.

syntax:

ii
String dt = obj.toString();

ath
faq:

aip
define length() method?

=>length() method is used to find the length of String.


hM
syntax:

int len = str.length();


tes

faq:

define charAt() method?


a
nk

=>charAt() method is used to retrieve character from the string based on

index value.
Ve

syntax:

char ch = str.charAt(index);

=================================================================

Assignment:

wap to read a String and display the reverse of String?


i/p : str = "language"

o/p : egaugnal

==================================================================

Ex-program:

wap to read a String and,display Vowels and Count of Vowels?

ii
ath
i/p : str = "language"

aip
Vowels : a u a e

Count : 4
hM
a tes
nk
Ve

Program : DemoString2.java
package maccess;
import java.util.*;
public class DemoString2 {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
try(s;) {
System.out.println("Enter the String:");
String str = s.nextLine();
int len = str.length();
int count=0;
System.out.print("Vowels : ");
for(int i=0;i<=len-1;i++)
{
char ch = str.charAt(i);//Char from index
switch(ch)
{
case 'a':

ii
case 'A':

ath
System.out.print(ch+" ");
count++;
break;
case 'e':

aip
case 'E':
System.out.print(ch+" ");
count++;
break;
hM
case 'i':
case 'I':
System.out.print(ch+" ");
count++;
break;
tes

case 'o':
case 'O':
System.out.print(ch+" ");
a

count++;
break;
nk

case 'u':
case 'U':
System.out.print(ch+" ");
Ve

count++;
break;
}//end of switch
}//end of loop
System.out.println("\nCount of Vowels :
"+count);
}//end of try with resource
}
}

o/p:

Enter the String:

java language programming

Vowels : a a a u a e o a i

ii
Count of Vowels : 9

ath
===================================================================

Assignment:

aip
wap to raed a String and,display Consonents and count of Consonents?
hM
Assignment:

Update above program displaying Vowels from the String,but display vowels

only once.
tes

===================================================================

faq:
a
nk

define ASCII code?

=>ASCII stands for 'American Standard Code for Information Interchange'


Ve

and which is unique code generated for each key pressed from the keyboard.

UpperCase Alphabets(A-Z) : 65 to 90

LowerCase Alphabets(a-z) : 97 to 122

Numbers(0-9) : 48 to 57
Program : DemoString3.java
package maccess;
public class DemoString3
{
public static void main(String[] args)
{
System.out.println("****UserCase Alphabets(A-

ii
Z)****");
for(int i=65;i<=90;i++)

ath
{
char ch = (char)i;//ASCII code to Char
System.out.print(ch+" ");

aip
}
System.out.println("\n****LowerCase
Alphabets(a-z)****");
for(int i=97;i<=122;i++)
hM
{
char ch = (char)i;//ASCII code to Char
System.out.print(ch+" ");
}
System.out.println("\n****Numbers(0-9)****");
tes

for(int i=48;i<=57;i++)
{
char ch = (char)i;//ASCII code to Char
a

System.out.print(ch+" ");
}
nk

}
}
Ve

o/p:

****UserCase Alphabets(A-Z)****

ABCDEFGHIJKLMNOPQRSTUVWXYZ

****LowerCase Alphabets(a-z)****
abcdefghijklmnopqrstuvwxyz

****Numbers(0-9)****

0123456789

===================================================================
=======

ii
ath
aip
hM
a tes
nk
Ve

You might also like