Java Programming: Data Types, Objects, and Classes, Essays (university) of Java Programming

Run the first Java Program Introduce the basic debugging e.g. step into, step through, watching variables Significance of a Class Main function inside a class Keywords associated with main function - public, static, void Differentiate Class and Object Creating class and creating objects Adding members to the class - variables and methods Running a simple program with a class and objects Introduction to concepts of Encapsulation and Abstraction Access Modifiers - private, public, static

Typology: Essays (university)

2016/2017

Uploaded on 11/14/2017

prags_nie
prags_nie 🇮🇳

1 document

1 / 112

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Advanced
Programming
Techniques
BITS Pilani Raghavan P
Piani| Dubai| Goa | Hyderabad
Session 1
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32
pf33
pf34
pf35
pf36
pf37
pf38
pf39
pf3a
pf3b
pf3c
pf3d
pf3e
pf3f
pf40
pf41
pf42
pf43
pf44
pf45
pf46
pf47
pf48
pf49
pf4a
pf4b
pf4c
pf4d
pf4e
pf4f
pf50
pf51
pf52
pf53
pf54
pf55
pf56
pf57
pf58
pf59
pf5a
pf5b
pf5c
pf5d
pf5e
pf5f
pf60
pf61
pf62
pf63
pf64

Partial preview of the text

Download Java Programming: Data Types, Objects, and Classes and more Essays (university) Java Programming in PDF only on Docsity!

Advanced

Programming

BITS Pilani Techniques Raghavan P

Piani| Dubai| Goa | Hyderabad

Session 1

BITS Pilani

Outline – Contact Session 1

  • (^) Introduce the Eclipse IDE

Run the first Java Program Introduce the basic debugging e.g. step into, step through, watching variables

  • (^) Significance of a Class

Main function inside a class Keywords associated with main function - public, static, void Differentiate Class and Object Creating class and creating objects Adding members to the class - variables and methods Running a simple program with a class and objects Introduction to concepts of Encapsulation and Abstraction Access Modifiers - private, public, static 2 2

Features of Java

  • (^) Familiar, Simple, Small
  • (^) Compiled and Interpreted
  • (^) Platform-Independent and Portable
  • (^) Object-Oriented
  • (^) Robust and Secure
  • (^) Distributed
  • (^) Multithreaded and Interactive
  • (^) High Performance

Bytecodes

Compiled Languages

Text Editor Compiler linker

Programmer

Source Code

.c file

Object Code

.o file

Notepad, emacs,vi

gcc

Executabl e Code

a.out file

Bytecodes

  • (^) Bytecode is the code

generated after the Java programs are compiled. This is the intermediate representations of Java programs. Bytecode is NOT executable code like “.exe” but this is java propriety intermediate code. Bytecode

Platform Independence

  • (^) Java Compiler - Java source code (file with extension

.java) to bytecode (file with extension .class)

  • (^) Bytecode - an intermediate form, closer to machine

representation

  • (^) A interpreter (virtual machine) on any target

platform interprets the bytecode.

  • (^) Porting the java system to any new platform

involves writing an interpreter.

  • (^) The interpreter will figure out what the equivalent

machine dependent code to run

Java Virtual Machine - JVM

The Java Virtual Machine

Class loader

Execution engine

Host operating system

Program Class files

The Java API’s class files

Native methods invocation

The Bytecode :

  • (^) Bytecode is a highly optimized set of instructions designed to be executed by the Java run-time system which is called the Java Virtual Machine(JVM).

Java Virtual Machine(JVM ):

  • (^) JVM is an interpreter for bytecode.
  • (^) JVM needs to be implemented for each

platform.

  • (^) Although the details of the JVM will differ from

platform to platform, all interpret the same java bytecode.

Two Paradigms

Process-Oriented model

  • (^) What is happening
  • (^) Characterizes a program as a series of linear steps(that is code)
  • (^) Code acting on data problems appear as programs grow larger and more complex

Object- Oriented programming

  • (^) Who is being affected
  • (^) Organizes a program around its data(Object)
  • (^) Characterized as Data controlling access to code

Encapsulation

  • (^) Encapsulation is the mechanism that binds

together code and the data. It manipulates and keeps both safe from outside interference and misuse (protective wrapper)

  • (^) Access to the code and data inside the wrapper is

tightly controlled through a well-defined interface.

For example in a car shifting gears does not turn on the headlights.

  • (^) Encapsulation is a strategy used as part of abstraction. Encapsulation refers to the state of objects - objects encapsulate their state and hide it from the outside; outside users of the class interact with it through its methods, but cannot access the classes state directly. So the class abstracts away the implementation details related to its state.
  • (^) Abstraction is a more generic term, it can also be achieved by (amongst others) subclassing. For example, the interface List in the standard library is an abstraction for a sequence of items, indexed by their position, concrete examples of a List are an ArrayList or a LinkedList. Code that interacts with a List abstracts over the detail of which kind of a list it is using.
  • (^) Abstraction is often not possible without hiding underlying state by encapsulation - if a class exposes its internal state, it can't change its inner workings, and thus cannot be abstracted.

Polymorphism

  • (^) Polymorphism is a feature that allows one

interface to

be used for a general class of actions. The specific action

is determined by the exact nature of the situation.

  • (^) One interface multiple methods.

Java Program Structure

  • (^) In the Java programming language:
    • (^) A program is made up of one or more

classes

  • (^) A class contains one or more methods
  • (^) A method contains program statements
  • (^) A simple Java application always

contains a method called main() in one of its class.