0% found this document useful (0 votes)
83 views

Java Unit I-1 PDF

Object-oriented programming concepts include objects, classes, encapsulation, abstraction, inheritance, polymorphism, and dynamic binding. Java is an object-oriented language that is compiled into bytecode and interpreted, making it platform-independent. It has features like being robust, secure, distributed, and multithreaded. Java works well for web applications as applets can be run locally or downloaded over the internet. It enhanced the capabilities of the world wide web by allowing animation, graphics, and interactivity through applets embedded in webpages. Common web browsers that support Java include HotJava, Netscape Navigator, and Internet Explorer.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
83 views

Java Unit I-1 PDF

Object-oriented programming concepts include objects, classes, encapsulation, abstraction, inheritance, polymorphism, and dynamic binding. Java is an object-oriented language that is compiled into bytecode and interpreted, making it platform-independent. It has features like being robust, secure, distributed, and multithreaded. Java works well for web applications as applets can be run locally or downloaded over the internet. It enhanced the capabilities of the world wide web by allowing animation, graphics, and interactivity through applets embedded in webpages. Common web browsers that support Java include HotJava, Netscape Navigator, and Internet Explorer.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

1.

Explain Basic Concepts Of Object-Oriented Programming/benefits of


OOPS?
Objects and classes :
Objects are the basic runtime entities in an object-oriented system.
A class is thus a collection of objects of similar type. For example, mango, apple and
orange are members of the class fruit.
Data Abstraction and Encapsulation :
The wrapping up of data methods into single unit (called class) is known as
Encapsulation. It is also called as data hiding.
Abstraction refers to the act of representing essential features without including the
background details or explanation.
Polymorphism
Polymorphism means the ability to take more than one form.
Polymorphism is a feature that allows one interface to be used for a general class of
actions.
Inheritance
Inheritance is the process by which the objects of one class acquire the property of
object of another class.

Advantages:
Inheritance provides the idea of reusability.
Time consuming.
Dynamic Binding
Binding refers to the linking of a procedures call to the code to be executed in
response to the call.
Dynamic binding means that the code associated with a given procedure call is not
known until the time of the call at run time.
Message communication
An object-oriented program consists of a set of objects that communicates with each
other.
1. Creating classes that define object and behaviors.
2. Creating objects from class definitions.
3. Establishing communication among objects.
Objects communicates with one another by sending and receiving information much the
same way as people pass messages to one another.

1
Eg: Employee. Salary (name);
***************************************************************************
2. Explain java features?
Compiled and Interpreted
 Usually a computer language is either compiled or interpreted.
 Java combines both these approaches.
 First, Java compiler translates source code into bytecode instructions.
 Bytecodes are not machine instructions and therefore, in the second stage, Java
interpreter generates machine code that can be directly executed by the
machine that is running the Java program.
Platform-Independent and Portable
 The most significant contribution of Java over other languages is its portability.
Java programs can be easily move from one computer to another.
 Changes and upgrades in operating systems and system resources will not force
any changes in Java programs.
Object-Oriented
 Java is a true object-oriented language.
 Almost everything in Java is an object.
 All program code and data reside within objects and classes.

Robust and Secure
 Java is a robust language.
 It provides many safeguards to ensure reliable code.
 It has strict compile time and run time checking for data types.
 Exception Handling- to handle series errors and eliminates any risk of
crashing the system.
Distributed
 It has the ability to share both data and programs.
 Java applications can open and enables multiple programmers at multiple
remote locations to collaborate and work together on a single project.
Simple, Small and Familiar
 Java is a small and simple language.
 Many features of C and C++ that are either redundant or sources of
unreliable code are not part of Java.
Multithreaded and Interactive
 Multithreaded means handling multiple tasks simultaneously.

2
 Java supports multithreaded programs.
 This means that we need not wait for the application to finish one task
before beginning another.
High Performance
 Java performance is impressive for an interpreted language, mainly due to
the use of intermediate bytecode.
 Java speed is comparable to the native C/C++.
Dynamic and Extensible
 Java is a dynamic language.
 Java is capable of dynamically linking in new class libraries, methods and
objects.
 Java programs support functions written in other languages such as C and
C++. These functions are known as native methods
*******************************************************************

3. How java differs from c and c++ ?

C JAVA
Size of type definition (statement C keyword) Not supported
Struct, union(datatype) Not supported
Auto, extern, register, signed unsigned Not supported
(type modifier key word)
Pointers Not supported
Not supported New operator like instance of and
>>>
Not supported Labeled, break, continue

C++ JAVA
Operator overloading Not supported
Template class Not supported
Multiple inheritance Interface
Pointer Not supported
Destructor Destructor replaced as a Finalize() function

3
4.Explain Java And Internet?
 Java is strongly with the Internet because of the fact that the application
program written in Java was HotJava, a web browser to run Java applets on
Internet.
 Internet users can use Java to create applet programs and run them locally
using a “Java-enabled browser” such as HotJava .
 They can also use a Java-enabled browser to download an applet located on a
computer anywhere in the internet and run it on his local computer.
 In fact java applets have made the Internet a true extension of the storage
system of the local computer.
 Internet users can also set up their Websites containing Java applets that
could be used by other remote users of Internet.
 Java a unique programming language for the Internet. In fact, due to this, Java
is popularly known as Internet language
***********************************************************************
5. Explain Java And World Wide Web?
 World Wide Web (WWW) is an open-ended information retrieval system
designed to be used in the Internet’s distributed environment.
 This system contains what are known as Web pages that provide both
information and controls.
 Before Java, the World Wide Web was limited to the display of still images
and texts.
 However, the incorporation of Java into Web pages has made it capable of
supporting animation, graphics, games and wide range of special effects.
 With support of Java, the web has become more interactive and dynamic.
 Java communicates with a Web page through a special tag called <APPLET>.
The following are the communication steps.
 The user sends a request for an HTML document to the remote computer’s
Web server is a program that accepts a request, processes the request, and
sends the required document.
 The HTML document is returned to the user’s browser. The document
contains the APPLET tag, which identifies the applet.
 The corresponding applet bytecode is transferred to the user’s computer. This
bytecode had been previously created by the Java source code file for that
applet.

4
 The Java-enabled browser on the user’s computer interprets the bytecodes and
provides output.
*****************************************************
6 Explain web browsers?
 Web browsers are used to navigate through the information found on the net.
 They allow us to retrieve the information spread across the Internet and
display it using the hypertext markup language (HTML).
Among other Web browsers, includes
 HotJava
 Netscape Navigator
 Internet Explorer
HotJava
HotJava is written entirely in Java and demonstrates the capabilities of Java
programming language.
When the Java language was first developed and ported to the Internet, no
browsers were available that could run Java applets.
HotJava is currently available for the SPARC/Solaris platform as well as
Windows 95, Windows NT and Windows XP.

Netscape Navigator
Netscape Navigator was from Netscape Communications Corporation, is a
general purpose browser that can run Java applets.
It has many useful features such as visual display about downloading process
and indication of number of bytes downloaded.
It also supports JavaScript, a scripting language used in HTML documents.

Internet Explorer
Internet Explorer is another popular browser developed by Microsoft for
Windows 95, NT and XP workstations.
Both the Navigator and Explorer use tool bars, icons, menus and dialog
boxes for easy navigation.
Explorer uses a just-in-time (JIT) compiler which increases the speed of
execution.
************************************************************************

5
7.Explain java program structure?

Document section This would help in a maintaining the


program
/*…..*/ Document comment
// single line comment
Package Statement Its include a package statement.
Ex: package package name;
Import Statement Include some import import statements.
eg: - import jva.io.*;
Interface Statements Include an interface concept. It’s like a
method
Class Definitions Classes are the primary and
essential elements of java program.
These classes are used to map the
object of real-world problems.
Main Method class Main method as its starting point of
{ the stand alone application.
Main method definition It’s a essential part of java program.
} Java program contains only one
main method.

****************************************************

6
8.Expalin Java Tokens?
 Smallest individual units in a program are known as tokens.
Java contains 5 types of tokens:
1. Reserved Keywords 2.Identifiers 3.Literals 4.Operators 5.Seperators

Tokens Description
Key Words  Java language has reserved 50 words as keywords
 Java keywords have specific meaning in java.
 We cannot use them as names for variables, classes, methods and so and
so.
Ex : for, import, private, void.

Identifiers  They are used for naming classes, methods, variables, objects, labels,
packages and interfaces in a program.
Rules
They can have alphabet, digit and the underscore and dollar sign
characters.
EX: average, sum
They must not begin with a digit. Ex: 1empname
Upper case and lower case letter are distinct. EX: Student, HelloJava
They can be of any length.

Literals :  That represent constant values to be stored in a variable


Type of literals :
Integer literals, Floating-point literals, Character literals, String literals
Boolean literals
Operators  One or more arguments and operates on them to produce a result.
Separators Parenthesis ( ),Braces {},Brackets[],semicolon, Comma, Period(.)

**********************************************************************

7
9. Explain java virtual machine?
* The java compiler produces an intermedia code known as bytecode for a machine
that does not exist. This Machine is called the Java Virtual Machine.
* It exists only onside the computer memory.
* It is simulated computer within the computer and does all major functions of a real
computer.
* Java program into byte code which is also referred as Virtual Machine code.

Java Program Java Compiler Virtual Machine

Source code Process of compilation Byte code

* The Virtual machine code is not machine specific. The machine specific code
(known as machine code) is generated by the Java Interpreter by acting as an intermediary
b/w the virtual machine and the real machine.

Byte Code Java Interpreter Machine Code

Virtual machine Real Machine


The java frame work act as the intermediately b/w the user and the JVM.

You might also like