Your SlideShare is downloading. ×
0
Core java
Core java
Core java
Core java
Core java
Core java
Core java
Core java
Core java
Core java
Core java
Core java
Core java
Core java
Core java
Core java
Core java
Core java
Core java
Core java
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Core java

353

Published on

Published in: Education
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
353
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
0
Comments
0
Likes
1
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Core JavaPresenting overview of core java Presented by Uday Sharma 1
  • 2. Agenda• Try-Catch• Read Input from Keyboard• Control Flow• Looping• Array• Exercises• Inheritance• Overriding• Abstract• Interface• Packages• Project work 2
  • 3. Try-catch blockTry – catch block is useful to try statement or syntax ifthere is any error catch block will handle exceptionSyntax Exceptiontry int a=10;{ int b=0; int c;// Body-------------- try{} c = a/b;catch(Exception e) }{ catch(Exception e)// Body------------ { System.out.println(e);} } 3
  • 4. Read Integer Input From Keyboardtry{int a;BufferedReader br = new BufferedReader(newInputStreamReader(System.in));System.out.println("Enter value of a= ");a = Integer.parseInt(br.readLine());//float y = Float.parseFloat(stdin.readLine());-- For float}catch(Exception e){} 4
  • 5. Read String Input From Keyboardtry{ while( (strLine = br.readLine()) != null) { if(strLine.equals("exit")) break; System.out.println("Line entered : " + strLine); } br.close(); } catch(Exception e) { System.out.println("Error while reading line from console : " + e); } 5
  • 6. Control flow statement• IF- ELSE boolean blnStatus = true;Syntax if() { if(blnStatus==true) { body; System.out.println("Status is true"); } } else { else { System.out.println("Status is false"); body; } } 6
  • 7. Nested if else• IF- ELSE int printOption =1;Syntax int scanOption =2; int copyOption =3; if() { int value = 1; body; if(value==1) { } System.out.println(“Priting….."); } else if() { else if(value==2){ body; System.out.println(“Scanning….."); } } else if(value==3){ else { System.out.println(“copyOption"); } body; else { } System.out.println(“Machine either in idle stage or switch off"); } 7
  • 8. For LoopSyntaxfor( <initialization> ; <condition> ; <statement> ){ <Block of statements>;}Examplefor(int i=0 ; i < 5 ; i++){ System.out.println(“i is : “ + i);} 8
  • 9. For loop example• Build pyramid***************• Build pyramid 2*************** 9
  • 10. Group work• Pyramid 3 • Numeric pyramid * 1 ** 12 *** 123 **** 1234 ***** 12345 ***** **** *** ** * 10
  • 11. While loopsyntaxwhile(<boolean condition>){ <Block of statements>; }Example while(i < 5) { System.out.println("i is : " + i); i++; } 11
  • 12. Do while loopSyntaxDo{ <Block of statements>;}while(<boolean condition>);Example do { System.out.println("i is : " + i); i++; }while(i < 5); 12
  • 13. Switch StatementSyntax The switch statement is Java’sswitch (expression) multiway branch statement. It{ provides an easy way to dispatchcase value 1 : execution to different parts ofstatement 1 ; break; your code based on the value of... an expression.case value N :statement N ; break;default :statements ; break;} 13
  • 14. Array in JavaSyntaxdataType[] arrayRefVar = new dataType[arraySize];dataType[] arrayRefVar = {value0, value1, ..., valuek};ExampleDouble[] myList = new double[10]; 14
  • 15. Design car• Design car parts 4 tyre (1- 2 front tyre and 3-4 back tyre), 4 doors (1- 2 front doors and 3-4 back doors), 4 headlight (2 front light and 2 break light), 1 body, 2 Glass (front and rear glass), 1 Mirror, 4 seat (2 front seat (Left is driver seat), and 2 back seat) . 15
  • 16. Java ExampeMake saperate class for below mentioned all functionalityand attach all classes using interitance.Note : Make super class Area with 2 memeber variable andextend it another classes. Triangle Square Area = ½ × b × h Area = a2 b = base a = length of side h = vertical height Rectangle Parallelogram Area = w × h Area = b × h w = width b = base h = height h = vertical height 16
  • 17. Java Overriding• The benefit of overriding is: ability to define a behavior thats specific to the sub class type. Which means a subclass can implement a parent calss method based on its requirement.• In object oriented terms, overriding means to override the functionality of any existing method. 17
  • 18. Animal Example 18
  • 19. Class Name: AnimalhasEye+Leg()+Run()+Jump()+eye()+Body() 19
  • 20. Class Name: GirrafehasLeghasTailhasColorhasHeight+Leg(hasLeg)+Run()+eye()+Tail(hasTail)+Body(hasColor,hasHeight) 20

×