Object-Oriented Programming (CS F213) Lecture - 2 (Introduction To Java)
Object-Oriented Programming (CS F213) Lecture - 2 (Introduction To Java)
Object-Oriented Programming (CS F213) Lecture - 2 (Introduction To Java)
Pilani Campus
2
BITS Pilani, Pilani Campus
The JavaTM Programming Language
• All source code is first written in plain text files ending with the .java
extension
• Those source files are then compiled into .class files by the javac
compiler
• A .class file does not contain code that is native to your processor;
it instead contains bytecodes — the machine language of the Java
Virtual Machine (Java VM)
• The java launcher tool then runs your application with an instance
of the Java Virtual Machine
3
BITS Pilani, Pilani Campus
The JavaTM Programming Language
4
BITS Pilani, Pilani Campus
The Java Platform
• Checklist
– The Java SE Development Kit
– A text editor
6
BITS Pilani, Pilani Campus
A Closer Look at HelloWorldApp
8
BITS Pilani, Pilani Campus
System.out.println
9
BITS Pilani, Pilani Campus
System.out.println
System.out.println("This is an argument");
10
BITS Pilani, Pilani Campus
class Bicycle {
int cadence = 0; The Bicycle
int speed = 0;
int gear = 1;
bike2.changeCadence(50);
bike2.speedUp(10);
bike2.changeGear(2);
bike2.changeCadence(40);
bike2.speedUp(10);
bike2.changeGear(3);
bike2.printStates();
} 12
} BITS Pilani, Pilani Campus
Questions
1. When you compile a program written in the Java programming language, the
compiler converts the human-readable source file into platform-independent code that
a Java Virtual Machine can understand. What is this platform-independent code called?
Answer: Bytecode
4. When declaring the main method, which modifier must come first, public or static?
Answer: They can be in either order, but the convention is public static
13
BITS Pilani, Pilani Campus
THANK YOU