Object Oriented Programming Midterm

Topics: Object-oriented programming, Java, Subroutine Pages: 10 (2088 words) Published: February 26, 2013
Java is simple such as it does not have any pointers, it has automatic memory allocation and garbage collector, and it has multiple inheritance with interfaces. Java is a platform-independent. Every Java source code is compiled to Java bytecode, which can be executed on any platform that has its own JVM without compilation. Modifiers – certain reserved words that specify the properties of the data, methods, and classes and how they can be used. Statements – a statement represents an action or a sequence of actions. Every statement in Java ends with a semicolon (;) ++i Blocks – are used to group the components of the program, for example class blocks and method block Classes – the class is the essential Java construct. Every Java program has at least one class. Programs are inside a class definition enclosed in blocks The main method provide the control of program flow. The JVM executes the Java application by invoking the main method. Rules to name a Java source file:

* If a class has no modifier define for the keyword class, that class is thus default. The file name can be any. * If a class has public modifier, the file name must be the same as that class * If a class has main method, that class should be public Therefore there must not be more than one public class in one file. Identifiers – special symbols to name programming entities such as variables, constants, methods, classes, and packages. An identifier is a sequence of characters that begins with a letter, _, or $, then following with letters, digits, _, $. It must not be a reserved word, must not be true, false, or null, and can be of any length.

Command-line arguments….java ClassName Hello World Hello ↲ World
java ClassName “Hello World” Hello World
java ClassName “First Num” 53 First Num ↲ 53
Expression – represents a computation involving values, variables, and operations that together evaluate a value system.out.println(++i); Constants – represent permanent data that never changes during execution of the program. Must be declared and initialized in the same statement. Using the keyword final Data types and Operations…

Type: byte, Range: -128 to 127, Storage Size: 8-bit signedType: short, Range: -32768 to 32767, Storage Size: 16-bit signed Type: int, Range: -2147483648 to 2147483647, Storage Size: 32-bit signedType: long, Range: -2^63 to 2^63 -1 , Storage Size: 64-bit signed Type: float, Storage Size: 32-bit signed, Negative Range: -3.4028235E+38 to -1.4E-45, Positive Range: 1.4E-45 to 3.40228235E+38 Type: double, Storage Size: 64-bit signed, Negative Range: -1.797693148623157E+308 to -4.9E-324, Positive Range 4.9E-324 to 1.797693148623157E+308 Widening data – casting a variable of a type with a small range to a variable type with a larger range, can be performed implicitly double d = 3; Narrowing data – casting a variable of a type with a larger range to a variable type with a smaller range, can be performed explicitly int i = (int)3.0; Conditional AND operator exp1 && exp2 If exp1 is false, do not evaluate exp2 Conditional OR operator exp1 || exp2 If exp1 is true, do not eval exp2 Unconditional AND operator exp1 & exp2 evaluates both exp1 and exp2 Unconditional OR operator exp1 | exp2 evaluates both exp1 and exp2 Conditional expression even = (number % 2 == 0) ? true : false; Overloaded Methods – two methods have the same class but different parameter lists within one class. The Java compiler determines which method is used based on the signature. Overloaded methods are based on different parameter lists. They are not based on different modifiers or return type Ambiguous invocation – there are two or more possible matches for an invocation of a method, but the compiler cannot determine the most specific match. It causes a compilation error Array – data structure that stores a fixed size sequential collection of elements of the same type double[] myList = new double[10]; Object –...
Continue Reading

Please join StudyMode to read the full document

You May Also Find These Documents Helpful

  • Java Programming Essay
  • JAVA Essay
  • Object Oriented Programming Essay
  • Comparison of Object Oriented and Structured Programming Essay
  • Lecture: Object-oriented Programming and A. Variable B. Essay
  • Java Programming- Chinmay Essay
  • Essay about Java Programming I Exam
  • Reusability: Object Oriented Programming Essay

Become a StudyMode Member

Sign Up - It's Free