Introduction to Object-Oriented Programming in Java: Unit 2, Cheat Sheet of Javascript programming

Java is a class-based, object-oriented programming language that is designed to have as few implementation dependencies as possible. It is intended to let application developers write once, and run anywhere (WORA), meaning that compiled Java code can run on all platforms that support Java without the need for recompilation. Java was first released in 1995 and is widely used for developing applications for desktop, web, and mobile devices. Java is known for its simplicity, robustness, and securit

Typology: Cheat Sheet

2022/2023

Uploaded on 03/23/2023

abdullah-rock
abdullah-rock 🇦🇪

10 documents

1 / 33

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
JAVA
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

Partial preview of the text

Download Introduction to Object-Oriented Programming in Java: Unit 2 and more Cheat Sheet Javascript programming in PDF only on Docsity!

JAVA

Introduction

Welcome to the course O bject O riented

P rogramming in JAVA. This course will cover a

core set of computer science concepts needed

to create a modern software application using

Java.

Java Milestones : 1990  Sun Microsystems decided to develop special software that could be used to manipulate consumer electronic devices. A team of Sun Microsystems programmers headed by James Gosling was formed to undertake this task. 1991  After exploring the possibility of most Object Oriented Programming Language C++, the team announced a new language named “Oak”. 1992  The team, known as a Green Project team by Sun, demonstrated the application of their new language to control a list of home appliances using a hand-held device with a tiny touch sensitive screen. 1993  The World Wide Web(WWW) appeared on the internet and transformed the text-based Internet into a Graphical-rich environment. The green Project team came up with the idea of developing Web Applets(tiny 03/23/2023 Unit 2 Programming in JAVA 4

1996  Java established itself not only a leader for Internet Programming but also as a general-purpose, object oriented programming language. Java found its home. The most striking feature of the language is that it is a platform-neutral language. Java is a first programming language that is not tied to any particular hardware or operating system. Features of Java :

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

Cont..

  • (^) Java Editions.

 J2SE (Java 2 Standard Edition) - to develop

client-side standalone applications or applets.

 J2ME (Java 2 Micro Edition ) - to develop

applications for mobile devices such as cell

phones.

 J2EE (Java 2 Enterprise Edition ) - to develop

server-side applications such as Java servlets

and Java Server Pages.

Why Java is Important

  • (^) Two reasons :
    • (^) Trouble with C/C++ language is that they are not portable and are not platform independent languages.
    • (^) Emergence of World Wide Web, which demanded portable programs
  • (^) Portability and security necessitated the

invention of Java

Java is architecture-neutral

JAVA Program Execution

Platform Independent

Compilation is the process of converting the code that you type into a language
that the computer understands-machine language. When you compile a
program, the compiler checks for syntactical errors in code and lists all the
errors on the screen. You have to rectify the errors and recompile the program
to get the machine language code. The Java compiler compiles the code to
bytecode that is understood by the Java environment.
The bytecode is the result of compiling a Java program. You can execute this
code on any platform. In other words, due to the bytecode compilation process
and interpretation by a browser, Java programs can be executed on a variety of
hardware and operating systems. The only requirement is that the system
should have a java-enabled Internet browser.The java compiler is written in
Java, and the interpreter is written in C. The Java Interpreter can execute Java
Code directly on any machine on which a Java interpreter has been installed.

Java Source Code Java Compiler Java Enabled Browser Java Interpreter Output Output Application Type Applet Type

Principal of OOPs

Object Oriented Programming (OOP) attempts to emulate the real world in software systems. The real world consists of objects, categorized in classes. In Object Oriented Programming, classes have attributes, represented by data member. The attributes distinguish an object of the class. Classes have behaviors, which are represented by methods. The methods define how an object acts or reacts. Feature of Object Oriented Programming : Information Encapsulation(Hiding) :- Objects provide the benefit of information hiding. Electrical writing in a television should not be tempered with, and therefore should be hidden from the user. Object Oriented programming allows you to encapsulate data that you do not want users of the object to access. Typically, attributes of a class are encapsulated. Abstraction :- Abstraction allows us to focus on only those parts of an object that concern us. Person operating the television does not need to know the intricacies of how it works. The person just needs to know how to switch it on, change channels, and adjust the volume.All the details that are unnecessary to users are encapsulated, leaving only a simple interface to interact with. Providing users with only what they need to know is known as abstraction. i.e. Abstraction lets us ignore the irrelevant details and concentrate on the essentials.

How is Java different from C…

  • (^) C Language:
    • (^) Major difference is that C is a structure oriented language and Java is an object oriented language and has mechanism to define classes and objects.
    • (^) Java does not support an explicit pointer type
    • Java does not have preprocessor, so we cant use #define, #include and #ifdef statements.
    • (^) Java does not include structures, unions and enum data types.
    • (^) Java does not include keywords like goto, sizeof and typedef.
    • Java adds labeled break and continue statements.
    • (^) Java adds many features required for object oriented programming.

How is Java different from C++…

  • (^) C++ language

Features removed in java:

 (^) Java doesn’t support pointers to avoid unauthorized access of memory locations.  (^) Java does not include structures, unions and enum data types.  (^) Java does not support operator over loading.  (^) Preprocessor plays less important role in C++ and so eliminated entirely in java.  (^) Java does not perform automatic type conversions that result in loss of precision.