1 / 25

Core & Advance Java For Beginner-PSK Technologies Pvt. Ltd. Nagpur

Are you Looking for the Best Institute for Java Online or Offline Training Course? PSK Technologies PVT.LTD. Nagpur offers Java training classes with live projects by expert trainers. Our Java training program is specially designed for Under-Graduates (UG), Graduates, working professionals, and also for Freelancers. We provide end to end learning on Java Domain with deeper dives for creating a winning career for every profile, For more information contact 9975288300 or visit our website pskitservices.com

Download Presentation

Core & Advance Java For Beginner-PSK Technologies Pvt. Ltd. Nagpur

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CORE JAVA • PSK TECHNOLOGIES PVT. LTD. Plot No-780, Near Durga Temple, Katol Road Chaoni, Nagpur-13 Phone: 9975288300 / 9970141466 Email: info@psktechnologies.co.in website: www.pskitservices.com

  2. CONTENT Method Overriding andoverloading Final and Instance of keyword String Handling Website: www.pskitservices.com Phone: 9975288300 / 9970141466

  3. Method Overriding andoverloading Polymorphism in java 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. Up Casting 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.println("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"); } public static void main (String args[]) { Animal a1,a2,a3; a1=new Animal(); a2=new Dog(); a3=new BabyDog(); a1.eat(); a2.eat(); a3.eat(); }} 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 a=new BabyDog1(); a.eat(); } } Website: www.pskitservices.com Phone: 9975288300 / 9970141466

  7. Final and InstanceOfKeyword • Instance of The java instance of operator is used to test whether the object is an instance of the specified type (class or subclass orinterface). The instance of in java is also known as type comparison operator because it compares the instance with type. It returns either true orfalse. If we apply the instance of operator with any variable that has null value, it returns false. Program: classSimple1 { public static void main(Stringargs[]) { Simple1 s=new Simple1(); System.out.println(s instanceofSimple1);//true } } Website: www.pskitservices.com Phone: 9975288300 / 9970141466

  8. Use of ‘instanceof’Keyword Program: /*Understanding Real use of instanceofin 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) { A a=(A)p;//Downcasting a.a(); } if(p instanceof B){ B b=(B)p;//Downcasting b.b(); 51 } } } //end of Call class class Test4 { public static void main(String args[]) { Printable p=new B(); Call c=new Call(); c.invoke(p); }} Website: www.pskitservices.com Phone: 9975288300 / 9970141466

  9. Final Keyword inJava 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. Java Final Variable If you make any variable as final, you cannot change the value of final variable (It will be constant). class Bike9{ final intspeedlimit=90;//final variable void run(){ speedlimit=400; } public static void main(String args[]){ Bike9 obj=new 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. classBike{ final void run(){System.out.println("running...");}} class Honda2 extendsBike{ public static void main(String args[]){ new Honda2().run();}} Website: www.pskitservices.com Phone: 9975288300 / 9970141466

  12. STRING HANDLING String Handling in Java 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.

  14. Program: • // Demonstrate indexOf() and lastIndexOf(). classindexOfDemo{ • public static void main(Stringargs[]) • {String s = "Now is the time for all good men " +o • come to the aid of theircountry."; • System.out.println(s); System.out.println("indexOf(t) = "+s.indexOf('t'));System.out.println("lastIndexOf(t) = " +s.lastIndexOf('t')); System.out.println("indexOf(the) = " +s.indexOf("the")); System.out.println("lastIndexOf(the) = "+s.lastIndexOf("the")); • System.out.println("indexOf(t, 10) = " +s.indexOf('t', 10)); System.out.println("lastIndexOf(t, 60) = " +s.lastIndexOf('t',60)); System.out.println("indexOf(the, 10) = " +s.indexOf("the", 10)); System.out.println("lastIndexOf(the, 60) = " +s.lastIndexOf("the", • 60));}} Website: www.pskitservices.com Phone: 9975288300 / 9970141466

  15. Program • // Demonstrate append(). class appendDemo • { public static void main(String args[]) • { String s; • int a = 40; • StringBuffersb = new StringBuffer(40); • // s = sb.append("a = ").append(a).append("!").toString(); • s = sb.append("a = ").append(a) .toString(); • System.out.println(s); }} Website: www.pskitservices.com Phone: 9975288300 / 9970141466

  16. 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*/ StringBuffersb = 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

  17. OUR SOFTWARE COURSES Website: www.pskitservices.com Phone: 9975288300 / 9970141466

  18. OUR HARDWARE COURSES MCITP HARDWARE NETWORKING LINUX CCNP CCNA Website: www.pskitservices.com Phone: 9975288300 / 9970141466

  19. OUR SERVICES WEBSITE DESIGNING & DEVELOPMENT Website: www.pskitservices.com Phone: 9975288300 / 9970141466

  20. IT TRAINING Website: www.pskitservices.com Phone: 9975288300 / 9970141466

  21. DIGITAL MARKETING Website: www.pskitservices.com Phone: 9975288300 / 9970141466

  22. LAPTOP & DESKTOP SALES AND SERVICES Website: www.pskitservices.com Phone: 9975288300 / 9970141466

  23. PSK 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

More Related