Sie sind auf Seite 1von 5

ASSIGNMENT

DRIVE - SPRING 2019

PROGRAM - MASTER OF COMPUTER APPLICATION

SEMESTER - IV

SUBJECT CODE & NAME - MCA 413 - PROGRAMMING IN JAVA

BK ID - B2119

NUMBER OF ASSIGNMNETS, CREDITS & MARKS 2, 4 Credits, 30 marks each

Assignment Set -1

Q.1. List any ten Java command tools with a short description of each. 1*10

Answer:-

Java command tools:-

Executable Java Tool Description


appletviewer Used to view applets without a Web browser (to run applets outside of a
web browser)
Java This command runs Java bytecode to launch Java applications.
Javac To compile Java source files (Java programs) to binary class files
(bytecode)
Javadoc This command is used to generate API documentation out of Java
Javah Creates C-language header and stub files from a Java class, which allows
the Java and C code to interact
Javap Disassembles Java files and prints out a representation of Java bytecode
Jcmd It is used to send diagnostic command request to the Java JVM. When we
run jcmd without arguments it lists the JVM processes that are running at
the moment.
Jdb Helps to find and fix problems in Java class.
Jhat It is a Java heap analysis tool. It is used to parse and browse a heap dump
file. This command parses the heap dump and launches a webserver. Then
we can browse the dump in a browser. jhat supports object query
language (oql) and also some pre-designed queries.
Jmc To monitor, analyze and debug Java applications.
Jvisualvm To monitor, analyze and debug running Java application via a GUI in visual
manner.
Jar To aggregate and compress multiple files into a singe JAR file.

Q.2. What are the different types of operators used in Java? 10

Answer:-

(i) Arithmetic Operators: - Addition, Subtraction, Multiplication, Division and Modulus are the
various arithmetic operations that can be performed in Java. Table a. lists different Arithmetic
Operators.
Table a: List of Arithmetic Operators

Operator Meaning Use Meaning


+ ADD op1+op2 Adds two or more operators.
- SUBTRACT op1-op2 Performs subtraction of two or more operators.
* PRODUCT op1*op2 Performs multiplication between two or more
(MULTIPLY) operators.
/ DIVISION op1/op2 Performs division between two operators.
% MODULOUS op1 % op2 Calculates the reminder left in division between two
operators.

Comparison / Relational Operators

In Java, to compare the values of two or more operators, comparison operators are used. Table b.
lists various Comparison Operators in Java.

Table b: List of Comparison Operators in Java

Operator Meaning Example Remarks


== Equal op1 = = op2 Checks if both the operators are equal or not.
!= Not Equal op1 != op2 Checks if the operators are not equal to each
other or not.
< Less than op1 < op2 Checks if the first operator is lesser than the
other operator or not.
> Greater than op1 > op2 Checks if the first operator is greater than the
other operator or not.
<= Less than or equal op1 <= op2 Checks if the operator is lesser than or equal
to the other operator.
>= Greater than or equal op1 >= op2 Checks if the first operator is greater than or
equal to the other operator.

Logical Operators:-

In Java, to perform Boolean operation on operands we use Logical operators. Table c. lists various
Logical Operators in Java.

Table c: List of Logical Operators in Java

Operator Meaning Example Remarks


&& Short-circuit AND op1 && op2 Returns TRUE if and only if both the operands
are TRUE.
|| Short-circuit OR op1 || op2 Returns true if any of the two operators are
TRUE.
! Logical unary NOT !op Return compliment of the value of the operands.
For example if the operand value is TRUE it will
return FALSE.
& Logical AND Op1 & op2 Returns true if both are true. Always op1 and
op2 will be evaluated.
| Logical OR Op1 | op2 Returns true if anyone is true. Always op1 and
op2 will be evaluated.
Q.3. Differentiate between packages and Interfaces. 10

Answer:-

Packages:-

To create a package is quite easy: simply include a package command as the first statement in a Java
source file. Any classes declared within that file will belong to the specified package. The package
statement defines a name space in which classes are stored. If you omit the package statement, the
class names are put into the default package, which has no name. (This is why you haven't had to
worry about packages before now.) While the default package is fine for short, sample programs, it
is inadequate for real applications. Most of the time, you will define a package for your code. This is
the general form of the package statement: package pkg;

Here, pkg is the name of the package. For example, the following statement creates a package called
MyPackage.

Package My Package;

Java uses file system directories to store packages. For example, the .class files for any classes you
declare to be part of MyPackage must be stored in a directory called MyPackage. Remember that
case is significant, and the directory name must match the package name exactly.

Interface:-

An interface is defined much like a class. This is the general form of an interface: access interface
name {return-type method-name1 (parameter-list); return-type method-name2 (parameter-list);
type final-varname1 = value; type final-varname2 = value; // ... return-type method-nameN
(parameter-list); type final-varnameN = value;}

Here, access is either public or not used. When no access specifier is included, then default access
results, and the interface is only available to other members of the package in which it is declared.
When it is declared as public, the interface can be used by any other code. name is the name of the
interface, and can be any valid identifier. Notice that the methods which are declared have no
bodies. They end with a semicolon after the parameter list. They are, essentially, abstract methods;
there can be no default implementation of any method specified within an interface. Each class that
includes an interface must implement all of the methods.

Here is an example of an interface definition. It declares a simple interface which contains one
method called callback ( ) that takes a single integer parameter.

interface Callback {

void callback (int param);

}
Assignment Set -2

Q.1. List and explain the different components of an event? 10

Answer:-

Components of an event:-

i. Event Object – When the user interacts with the application by pressing a key or clicking a mouse
button, an event is generated. The operating system traps this event and the data associated with
it, for example, the time at which the event occurred, the event type (like a keypress or a mouse
click). This data is then passed on to the application to which the event belongs. In Java, events are
represented by objects that describe the events themselves. Java has a number of classes that
describe and handle different categories of event.

ii. Event Source – An event source is an object that generates an event. For example, if you click on a
button, an ActionEvent object is generated. The object of the ActionEvent class contains
information about the event.

iii. Event-handler – An event-handler is a method that understands the event and processes it. The
event-handler method takes an event object as a parameter.

Q.2. What is JDBC? List down the steps to load ODBC driver? 10

Answer: - ODBC is the abbreviation for Open Database Connectivity, a standard database access
method developed by Microsoft Corporation. The goal of ODBC is to make it possible to access any
data from any application, regardless of which database management system (DBMS) is handling the
data. ODBC manages this by inserting a middle layer, called a driver, between an application and the
DBMS. The purpose of this layer is to translate the queries of the application into commands that
the DBMS understands. For this to work, both the application and the DBMS must be ODBC-
compliant i.e. the application must be capable of issuing ODBC commands and the DBMS must be
capable of responding to them.

Steps to load ODBC driver:-

i. Click on the ODBC Data Source icon in the Control Panel.


ii. Click on Add.
iii. Select the SQL Server option from the list and click on Finish.
iv. Select a name for the data source and click on the Next button.
v. Select with SQL Server authentication using login ID and Password entered by the user.
vi. Select the database that you want to use and click on Next.
vii. Click on Finish.
viii. Click on Test Data Source to check for proper connectivity and click on OK.

Q.3. Write short notes on: a) CORBA b) BeanBox 5+5

Answer:-

a) CORBA: - CORBA stands for Common Object Request Broker Architecture. RMI needs the 2
objects participating in communication be written in Java. CORBA is a distributed computing
technology where the participating objects need not only be written in Java.
i. Java IDL is a technology for distributed objects-that is, objects interacting on different platforms
across a network.

ii. Java IDL is similar to RMI (Remote Method Invocation), which supports distributed objects written
entirely in the Java programming language. However, Java IDL enables objects to interact
regardless of whether they’re written in the Java programming language or another language such
as C, C++, COBOL, or others.

iii. Java IDL is based on the Common Object Request Brokerage Architecture (CORBA), an industry-
standard distributed object model.

iv. A key feature of CORBA is IDL, a language-neutral Interface Definition Language. Each language
that supports CORBA has its own IDL mapping and as its name implies, Java IDL supports the
mapping for Java. CORBA and the IDL mappings are the work of an industry consortium known as
the OMG, or Object Management Group.

v. To support interaction between objects in separate programs, Java IDL provides an Object Request
Broker, or ORB. The ORB is a class library that enables low-level communication between Java IDL
applications and other CORBA-compliant applications.

Example: The Hello Client-Server: - This tutorial teaches the basic tasks in building a CORBA
distributed application using Java IDL. You will build the classic Hello World program as a distributed
application. The Hello World program has a single operation that returns a string to be printed.

i. The client (applet or application) invokes the sayHello operation of the HelloServer.
ii. The ORB transfers that invocation to the server object registered for IDL interface.
iii. The server’s sayHello method runs, returning a Java String.
iv. The ORB transfers that String back to the client.
v. The client prints the value of the String.

b) BeanBox: - The BeanBox is a very simple test container. It allows you to try out both the BDK
example beans and your own newly created beans.

The BeanBox allows you to:

a. Drop beans onto a composition window.


b. Resize and move beans around.
c. Edit the exported properties of a bean.
d. Connect a bean event source to an event handler method.
e. Connect together bound properties on different beans.
f. Save and restore sets of beans.
g. Make applets from beans.
h. Get an introspection report on a bean.
i. Add new beans from JAR files.

Note that the BeanBox is intended as a test container and as a reference base, but it is not intended
as a serious application development tool.

Das könnte Ihnen auch gefallen