Title: Core & Advance Java Training For Beginner-PSK Technologies Pvt. Ltd. Nagpur
1CORE JAVA
- PSK TECHNOLOGIES PVT. LTD.
Plot No-780, Near Durga Temple, Katol Road
Chaoni, Nagpur-13 Phone 9975288300 /
9970141466 Email info_at_psktechnologies.co.in
website www.pskitservices.com
2CONTENT
- Method Overriding and overloading
- Final and Instance of keyword
- String Handling
-
Website www.pskitservices.com Phone 9975288300
/ 9970141466
3 Method Overriding and overloading
- Polymorphism in java is a concept by which we can
perform a single action by different ways.
Polymorphism is derived from 2 Greek
words poly and morphs. The word "poly" means
many and "morphs" means forms. So polymorphism
means many forms. - There are two types of polymorphism in java
compile time polymorphism and runtime
polymorphism. We can perform polymorphism in java
by method overloading and method overriding. - If you overload static method in java, it is the
example of compile time polymorphism. Here,
we will focus on runtime polymorphism in
java.
Website www.pskitservices.com Phone 9975288300
/ 9970141466
4- Runtime Polymorphism in Java
- Runtime polymorphism or Dynamic Method Dispatch
is a process in which a call to an overridden
method is resolved at runtime rather than
compile-time. - In this process, an overridden method is called
through the reference variable of a
superclass. The determination of the
method to be called is based on the object being
referred to by the reference variable.
When reference variable of Parent class refers to
the object of Child class, it is known as up
casting. class Bike void run()System.out.print
ln("running") 47 class Splender extends
Bike void run()System.out.println("running
safely with 60km") public static void
main(String args) Bike b new
Splender()//upcasting b.run()
Website www.pskitservices.com Phone 9975288300
/ 9970141466
5- Java Runtime Polymorphism With Multilevel
Inheritance
- class Animal
-
- void eat()System.out.println
- ("eating")
-
- class Dog extends Animal
-
- void eat()System.out.println
- ("eating fruits")
-
- class BabyDog extends Dog
- void eat()System.out.println
- ("drinking milk")
-
Website www.pskitservices.com Phone 9975288300
/ 9970141466
6- /BabyDog is not overriding the eat() method, so
eat() method of Dog class is invoked./ - class Animal
- void eat()System.out.println("animal is
eating...") -
- class Dog extends Animal
- void eat()System.out.println("dog is
eating...") -
- class BabyDog1 extends Dog
- public static void main(String args)
- Animal anew BabyDog1()
- a.eat()
-
Website www.pskitservices.com Phone 9975288300
/ 9970141466
7Final and Instance Of Keyword
- The java instance of operator is used to test
whether the object is an instance of the
specified type (class or subclass or interface). - The instance of in java is also known as type
comparison operator because it compares
the instance with type. It returns either true or
false. - If we apply the instance of operator with any
variable that has null value, it returns false. - Program
- class Simple1
-
- public static void main(String args)
-
- Simple1 snew Simple1()
- System.out.println(s instanceof Simple1)//true
-
-
Website www.pskitservices.com Phone 9975288300
/ 9970141466
8- Use of instanceof Keyword
- Program
- /Understanding Real use
- of instanceof in java/
- interface Printable
-
- class A implements Printable
- 50
- public void a()
- System.out.println("a method")
-
- class B implements Printable
- public void b()
- System.out.println("b method")
-
- class Call
- void invoke(Printable p)
- //upcasting
- if(p instanceof A)
-
Website www.pskitservices.com Phone 9975288300
/ 9970141466
9- The final keyword in java is used to restrict the
user. The java final - keyword can be used in many context. Final can
be - 1. variable
- 2. method
- 3. class
- The final keyword can be applied with the
variables, a final variable that have no
value it is called blank final variable or
uninitialized final variable. It can be
initialized in the constructor only. - The blank final variable can be static also which
will be initialized in the static block only.
We will have detailed learning of these. Let's
first learn the basics of final keyword.
Website www.pskitservices.com Phone 9975288300
/ 9970141466
10- If you make any variable as final, you cannot
change the value of - final variable (It will be constant).
- class Bike9
- final int speedlimit90//final variable
- void run()
- speedlimit400
-
- public static void main(String args)
- Bike9 objnew Bike9()
- obj.run()
-
- //end of class
- class Bike
- final void run()System.out.println("running")
-
- 53
- class Honda extends Bike
- void run()System.out.println("running safely
with 100kmph")
Website www.pskitservices.com Phone 9975288300
/ 9970141466
11- public static void main(String args)
- Honda honda new Honda()
- honda.run()
-
- class Honda1 extends Bike
- void run()System.out.println("running safely
with 100kmph") - public static void main(String args)
- Honda1 honda new Honda()
- honda.run()
-
- Is final method inherited?
Yes, final method is inherited but you cannot
override it. class Bike final void
run()System.out.println("running...") class
Honda2 extends Bike public static void
main(String args) new Honda2().run()
Website www.pskitservices.com Phone 9975288300
/ 9970141466
12STRING HANDLING
- The basic aim of String Handling concept is
storing the string data in the main memory
(RAM), manipulating the data of the String, and
retrieving the part of the String etc.
String Handling provides a lot of concepts
that can be performed on a string such as
concatenation of string, comparison of
string, find sub string etc.
Java String contains an immutable sequence of
Unicode characters. Java String is differ
from string in C or C, where (in C or C)
string is simply an array of char. String class
is encapsulated under java.lang package.
Website www.pskitservices.com Phone 9975288300
/ 9970141466
13- Java String Class Methods
- The java.lang.String class provides many useful
methods to perform operations on sequence of char
values.
No Method Description
1 char char At(int index) Returns char value for The particular index
2 int length() returns string length
3 static String format(String format, Object... args) Returns a formatted string.
4 static String format(Localel,String format, Object... args) Returns formatted string with given locale.
5 String substring(int begin Index) Returns substring for given begin index
6 String substring(int begin Index, int end Index) Returns substring for given begin index and end index.
7 boolean contains(Char Sequences) Returns true or false after matching the Ssequence of char value.
8 static String join(Char Sequence delimiter, Char Sequence... elements) Returns a joined string.
1410 boolean equals(Object another) Checks the equality of string with the given object.
11 Boolean is Empty() Checks if string is empty.
12 String concat(String str) Concatenates the specified string.
13 String replace(char old, char new) Replaces all occurrences of the specified char value.
14 String replace(Char Sequence old, Char Sequence new) Replaces all occurrences of the specified Char Sequence.
15 static String equals Ignore Case(String another) Compares another string. It doesn't check case.
16 String split(String regex) Returns a split string matching regex.
17 String split(String regex, int limit) Returns a split string matching regex and limit
18 String intern() Returns an interned string.
19 int index Of(int ch) Returns the specified Char value index.
1520 int index Of(int ch, int from Index) Returns the specified char value index starting with given index.
21 int index Of(String substring) Returns the specified substring index.
22 int index Of(String substring, int from Index) Returns the specified substring index starting with given index.
23 String to Lower Case() Returns a string in lowercase.
24 String to Lower Case(Locale l) Returns a string in lowercase using specified locale.
25 String to Upper Case() Returns a string in uppercase.
26 String to Upper Case(Locale l) Returns a string in uppercase using specified locale.
27 String trim() Removes beginning and ending spaces of this string.
28 static String value Of(int value) Converts given type into string. It is an overloaded method.
16- Program
- // Demonstrate indexOf() and lastIndexOf().
class indexOfDemo - public static void main(String args)
- String s "Now is the time for all good men "
o - come to the aid of their country."
- System.out.println(s) System.out.println("indexO
f(t) " s.indexOf('t'))System.out.println("last
IndexOf(t) " s.lastIndexOf('t'))
System.out.println("indexOf(the) "
s.indexOf("the")) System.out.println("lastIndex
Of(the) " s.lastIndexOf("the")) - System.out.println("indexOf(t, 10) "
s.indexOf('t', 10)) System.out.println("lastInd
exOf(t, 60) " s.lastIndexOf('t',60))
System.out.println("indexOf(the, 10) "
s.indexOf("the", 10)) System.out.println("lastI
ndexOf(the, 60) " s.lastIndexOf("the", - 60))
Website www.pskitservices.com Phone 9975288300
/ 9970141466
17- Program
- // Demonstrate append(). class appendDemo
- public static void main(String args)
- String s
- int a 40
- StringBuffer sb new StringBuffer(40)
- // s sb.append("a ").append(a).append("!").toS
tring() - s sb.append("a ").append(a) .toString()
- System.out.println(s)
Website www.pskitservices.com Phone 9975288300
/ 9970141466
18- Program
- // StringBuffer length vs. capacity. class
StringBufferDemo - public static void main(String args)
- /StringBuffer() The default constructor (the
one with no - parameters) reserves room for 16 characters
without reallocation. - StringBuffer is mutable/ StringBuffer sb new
StringBuffer("Hello") - System.out.println("buffer " sb)
- System.out.println("length " sb.length())
- System.out.println("capacity "
sb.capacity())
Website www.pskitservices.com Phone 9975288300
/ 9970141466
19OUR SOFTWARE COURSES
Website www.pskitservices.com Phone 9975288300
/ 9970141466
20OUR HARDWARE COURSES
MCITP
NETWORKING
HARDWARE
LINUX
CCNP
CCNA
Website www.pskitservices.com Phone 9975288300
/ 9970141466
21OUR SERVICES
WEBSITE DESIGNING DEVELOPMENT
Website www.pskitservices.com Phone 9975288300
/ 9970141466
22IT TRAINING
Website www.pskitservices.com Phone 9975288300
/ 9970141466
23DIGITAL MARKETING
Website www.pskitservices.com Phone 9975288300
/ 9970141466
24LAPTOP DESKTOP SALES AND SERVICES
Website www.pskitservices.com Phone 9975288300
/ 9970141466
25PSK TECHNOLOGIES PVT. LTD. IT COMPANY
FOLLOW US ON
Address Plot no-780, Near Durga Temple,
Katol Road Chhaoni, Nagpur-13
https/www.pskitservices.com
Contact 9975288300