What is Java Object Oriented Programming

October 26, 2017 | Author: apex_tgi | Category: Java
Share Embed

Short Description

Description: A class is the blueprint from which individual objects are created. In the real world, you'll often fin...


What Is Inheritance? Passin$ the basic property of a parent class into its child class is "nown as Inheritance. E%ample& Mountain bikes, road bikes, and tandem bikes, for example, all share the characteristics of bicycles (current speed, current pedal cadence, current gear). What Is Abstraction? Abstraction is the force that hide private implementation details behind public interfaces. Or 'ou can say that showin$ only relevant information is "nown as Abstraction. E%ample&   Withdrawin$ money from A() machine is a $ood e%ample of abstraction. What Is Encapsulation? *idin$ the comple%ity or wrappin$ of data into a sin$le capsule or module is "nown as Encapsulation. (o achieve encapsulation in your +ava pro$ram you should declare all the instance variable as private and the method that use these variable as public What Is Polymorphism? What Is a Pac"a$e?  A package is a namespace that organizes a set of related classes and interfaces. Conceptually you can think of packages as being similar to different folders on your computer.  What are the four OOPs principles and define them?  What is inheritance?  What is Abstraction?  What is multiple inheritance?  What can be the state and behavior of a computer? In +ava Pro$rammin$ an identifier is a name of a variable  a class or a method. Identifier starts with a letter underscore or dollar si$n,- subse/uent character can be di$its 0ollowin$s are valid identifier&   Identifier    user1ame   2ser3name   3sys3var4   -chan$e  6not used  66added in 4.7  666added in 4.8 (here are ei$ht primitive types in +ava Pro$rammin$ Operators are special symbols that perform specific operations on one two or three operands  and then return a result. (here are&   Arithmetic Operators   2nary Operators   Assi$nment Operator    ;itwise and ;it shift Operator     7 ; tatements tatements are rou$hly e/uivalent to sentences in natural lan$ua$es. A statement   forms a complete unit of e%ecution. (he followin$ types of e%pressions can be made into a statement by terminatin$ the e%pression with a semicolon ,@. ;loc"s A block   is a $roup of ero or more statements between balanced braces and can be used anywhere a sin$le statement is allowed. class ;loc"Bemo   public static void main,trin$D ar$s   boolean condition = [email protected]  if ,condition  FF be$in bloc" 4 ystem.out.println,GCondition is true.G@ H FF end bloc" one else  FF be$in bloc" 7 ystem.out.println,GCondition is false.G@  H FF end bloc" 7 H H   (he if#then and if#then#else tatements   (he switch tatement   (he while and do#while tatements   (he for tatement (he if#then statement is the most basic of all the control flow statements. It tells your pro$ram to e%ecute a certain section of code only if   a particular test evaluates to true. void apply;ra"es,    if ,is)ovin$  FF the GifG clause& bicycle must be movin$ currentpeed##@ FF the GthenG clause& decrease current speed  H H (he if#then#else statement provides a secondary path of e%ecution when an GifG clause evaluates to false. void apply;ra"es,    if ,is)ovin$   currentpeed##@  H  else   ystem.err.println,G(he bicycle has already stoppedG@ H  H class IfElseBemo   public static void main,trin$D ar$s   int testscore = [email protected]  char [email protected] if ,testscore L= M:   $rade = [email protected]  H else if ,testscore L= N:  $rade = !;[email protected] H  else if ,testscore L= J:   $rade = [email protected] H  else if ,testscore L= K:   $rade = [email protected] H  else  $rade = [email protected] H  ystem.out.println,Grade = G > $rade@ H H 2nli"e if#then and if#then#else statements the switch statement can have a number of possible e%ecution paths. A switch wor"s with the byte short char and int primitive data types. public class witchBemo   public static void main,trin$D ar$s   int day = [email protected]  trin$ day[email protected]  switch ,month   case 4& daytrin$ = G[email protected] brea"@  case 7& daytrin$ = G)[email protected] brea"@  case & daytrin$ = G([email protected] brea"@  case 8& daytrin$ = [email protected] brea"@  case 9& daytrin$ = G([email protected] brea"@  case K& daytrin$ = [email protected] brea"@  case J& daytrin$ = G[email protected] brea"@  default&daytrin$ = GInvalid [email protected] brea"@  H  ystem.out.println,daytrin$@  H H
View more...


Copyright © 2017 DOCTUTS.COM Inc.