Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Standard view
Full view
of .
Save to My Library
Look up keyword or section
Like this
P. 1
Java 03

Java 03

Ratings: (0)|Views: 400 |Likes:
Published by Mukesh Kumar

More info:

Published by: Mukesh Kumar on May 06, 2011
Copyright:Attribution Non-commercial


Read on Scribd mobile: iPhone, iPad and Android.
download as DOC, PDF, TXT or read online from Scribd
See more
See less





Solutions to Chapter One Questions
Why is Java known as a platform-neutral language?
Java is known as platform-neutral language because Java's bytecodes are designed to be read,interpreted, and executed in exactly the same manner on any computer hardware or operating systemthat supports a Java run-time.
How is Java more secure than other languages?
One of the potential terrors of the Internet is the possibility of security breaches- viruses that infectyour computer, or hackers who take advantage of a software glitch to invade your personalcyberspace and make off with confidential information.Applets, which are Java programs, are automatically downloaded when a Web page is displayed. Javaapplets, by default, execute within the Java executing environment and are limited to the environment.This means, an applet cannot access the local file system or other programs of the system where itexecutes. This reduces the chance that simply viewing someone's page might harm your system or data. No system is absolutely reliable and none will ever be; but Java represents the state-of-the-art inreducing the chances of a disaster.
What is multithreading? How does it improve the performance of Java?
In a multithreading environment, a thread is the smallest unit of dispatchable code. This means that asingle program can perform two or more tasks simultaneously. For instance a text editor can formattext at the same time that it is printing.The benefit of Java's multithreading is that the main loop/polling mechanism is eliminated. Onethread can pause without stopping other parts of the program. For example, the idle time created whena thread reads data from a network or waits for user input can be utilized elsewhere. When a thread blocks in a Java program, only the single thread that is blocked pauses. All other threads continue torun.
List at least seven major differences between C and Java.
The following are the differences between C and Java:1Java does not have a preprocessor, and as such, does not have macros like#define. Constants can be created by using the final modifier when declaringclass and instance variables.2In Java, all methods are tied to classes. Java does not support stand-alonemethods.3Java does not include the const keyword as present in C or the ability to pass by const reference explicitly.4In Java strings are implemented as objects and not as an array of null-terminated characters.5Java has some additional primitive data types like byte and Boolean. Datatypes in Java have a fixed size regardless of the operating system used.6The goto keyword does not exist in Java (it's a reserved word, but currentlyunimplemented). You can, however, use labeled breaks and continues to break out of and continue executing complex switch or loop constructs.7Java does not use pointers.8In Java, arrays are real objects because you can allocate memory using the
new operator.
How is Java strongly associated with the Internet?
Internet users can use Java to create applet programs and run them locally using "Java-enabled browsers" such as HotJava. They can also use a Java-enabled browser to download an applet locatedon a computer anywhere in the Internet and run it on their local computer. Internet users can also setup their websites containing java applets that could be used by other remote users of the Internet.
What is Hypertext Markup Language? Describe its role in the implementation of Java applets.
Hypertext Markup Language or HTML is a markup language that uses predefined tags to specify the browser how it needs to display a Web page.Browsers allow us to retrieve the information from the Internet and display it using the HypertextMarkup Language (HTML). HotJava, Netscape Navigator and Internet Explorer are some popular Web browsers. A Web page can embed Java applets. To embed an applet, the <Applet> tag is used inthe HTML document. When a browser encounters the <Applet> tag it loads the applet and executes itwith the browser Java Virtual Machine (JVM).
List out primary goals of Java Technology.
The primary goals of Java technology are:1To provide an easy to use language by avoiding pitfalls of other languagesand enables users to create clear and streamlined code.2To provide an interpreted environment for improved speed of developmentand code portability.3To provide a way for programs to run more than one thread of activity.4To furnish better security.
Why is Java considered ideal for network communication?
Java is considered ideal for network communication because it is a platform independent language.Java enables an application to be executed on any network. The built-in classes of Java supportTCP/IP and UDP protocols used for network communication. Java supports the Client-Server modelfor network communication.
What is a bytecode?
Bytecode is a compiled format of a Java program. Once a Java program is converted into bytecode itcan be transferred across the network and executed by a Java Virtual Machine (JVM).
What is an appletviewer?
An appletviewer allows you to run an applet without the overhead of running a Web browser.
Define Garbage Collection.
Garbage Collection is a process that automatically frees the memory of objects that are no longer inuse. There is no specification of a technique for garbage collection. The implementation has been leftto vendors.
Solutions to Chapter Two Questions
What is object-oriented programming? How is it different from the procedure-oriented programming?
Object- oriented programming is a method of implementation in which programs are organized as co-operative collection of objects, each of which represents an instance of some class and whose classesall members of a hierarchy of classes united in inheritance relationships.With procedural programming you are able to combine returning sequences of statements into onesingle place. A procedure call is used to invoke the procedure. After the sequence is processed, flowof control proceeds right after the position where the call was made
How are data and methods organized in an object-oriented program?
In an object-oriented program, a set of variables and functions used to describe an object constitutes a"class".A class defines the structure and behavior (data and method) that will be shared by a set of objects.Each object of a given class contains the structure and behavior defined by the class, as if it werestamped out of a mould in the shape of a class. A class is a logical construct. An object has physicalreality. When you create a class, you will specify the code and data that will constitute that class.Collectively, these elements are called the members of the class. Specifically, the data defined by theclass are referred to as member variables or instance variables. The code that operates on that data isreferred to as member methods or just methods, which define the use of the member variables.
What are unique advantages of an object-oriented programming paradigm?
OOP offers several advantages to both the program designer and the user. The important advantagesare:
: Elimination of redundant code and use of existing classesthrough inheritance. Thus provides economy of expression.
: Programs can be the built from standard working modules.
: Principle of information hiding helps programmer to build secure programs.
Easy mapping
: Object in the problem domain can be directly mapped to theobjects in the program.
: Can be easily upgraded from small programs to large programs.Object-oriented systems are also resilient to change and evolve over time in a better way.
Easy management
: Easy management of software complexity.

Activity (2)

You've already reviewed this. Edit your review.
1 thousand reads
1 hundred reads

You're Reading a Free Preview

/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->