Download BI0037

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
SMU-DDE-Assignments-Scheme of Evaluation
PROGRAM
SEMESTER
SUBJECT CODE &
NAME
BK ID
DRIVE
MARKS
Q.
No
1
A
MSC BIOINFORMATICS
3
BI0037
PROGRAMMING FOR BIOINFORMATICS IV
(JAVA PROGRAMMING)
B0831, B0832
WINTER 2015
60
Question
Marks
Total
Marks
(Book Id- B0831, Unit 4, Page No. 110)
5
10
Explain the packages and Interfaces in JAVA.
Packages
In the preceding section, the name of each example class was taken from the
same name space. This means that a unique name had to be used for each class
to avoid name collisions. After a while, without some way to manage the name
space, you could run out of convenient, descriptive names for individual
classes. You also need some way to be assured that the name you choose for a
class will be reasonably unique and not collide with class names chosen by
other programmers.
 Defining a Package
 Understanding CLASSPATH
Interface
Using the keyword interface, you can fully abstract a class' interface from its
implementation. That is, using interface, you can specify what a class must do,
but not how it does it. Interfaces are syntactically similar to classes, but they
lack instance variables, and their methods are declared without any body. In
practice, this means that you can define interfaces which don't make
assumptions about how they are implemented. Once it is defined, any number
of classes can implement an interface.


2
5
Defining an Interface
Some uses of interfaces
Explain ten features of JAVA.
(Book Id- B0831, Unit 1, Page No.
2)
A
Features of JAVA (any 10 each carries 1 mark)
 Java is a simple language that can be learned easily, even if you have
just started programming.
 A Java programmer need not know the internal of Java. The syntax of
Java is similar to C++. Unlike C++, in which the programmer handles
memory manipulation, Java handles the required memory
manipulations, and thus prevents errors that arise due to improper
10X1
10
SMU-DDE-Assignments-Scheme of Evaluation
3
memory usage.
 Java defines data as objects with methods that support the objects. Java
is purely object-oriented and provides abstraction, encapsulation,
inheritance and polymorphism.
 Java is tuned of Web. Java programs can access data across the Web as
easily as they access data from a local system.
 Java is both interpreted and compiled. The code is compiled to a byte
code that is binary and platform independent.
 When you compile a piece of code, all the errors are listed together.
You can execute only when all the errors are rectified. An interpreter,
on the other hand, verifies the code and executes it line by line.
 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 using a compiler, the compiler checks for syntactic
errors in code and list all the errors on the screen.
 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.
 Write Java event if they have different machines with different
operating systems.
 Java forces you to handle unexpected errors. This ensures that Java
programs are robust (reliable), and bug free and do not crash.
 Due to strong type-checking done by Java on the user’s machine, any
changes to the program are tagged as error and the program will not
execute. Java is, therefore, secure.
 Java is faster than other interpreter-based language like BASIC since it
is compiled and interpreted.
 Multithreading is the ability of an application to perform multiple tasks
at the same time.
 You can create multithreading programs using Java. The core of Java is
also multithreaded.
 The following definition of Java by Sun Microsystems lists all the
features of Java.
 ‘Java is a simple, Object-oriented, distributed, interpreted, robust,
secure, architecture neural, portable, high-performance, multithreaded,
and dynamic language’.
List out the differences between errors and exceptions. Discuss the different types of Exception.
(Book Id- B0831, Unit 5, Page No. 101)
SMU-DDE-Assignments-Scheme of Evaluation
Definition of an Exception
A
4
A
The term exception denotes an exceptional event. It can be defined as an
abnormal event that occurs during program execution and disrupts the normal
flow of instruction.
Error-handling becomes a necessity when you develop applications that need to
take care of unexpected situations. The unexpected situations that may occur
during program execution are:
 Running out of memory
 Resource allocation errors.
 Inability to find a file.
 Problems in network connectivity.
Java has several predefined exceptions. The most common exceptions that you
may encounter are described below.
 Arithmetic Exception
This exception is thrown when an exceptional arithmetic condition has
occurred. For example, a division by zero generates such an exception.
 NullPointer Exception
This exception is thrown when an application attempts to use null where an
object is required. An object that has not been allocated memory holds a
null value. The situations in which an exception is thrown include:
 Using an object without allocating memory for it.
 Calling the methods of a null object.
 Accessing or modifying the attributes of a null object.
 ArrayIndexOutOfBounds Exception
The exception ArrayIndexOutOfBounds Exception is thrown when an
attempt is made to access an array element beyond the index of the array.
For example, if you try to access the eleventh element of an array that’s has
only ten elements, the exception will be thrown.
Answer the following:
a) Write Java program to print the address of the study center.
b) Write a Java program to find the sum of 1+3+5+…. for 10 terms in the series.
a) Write proper program and output
b) Write proper program and output
5
Write a program to copy one file to another file.
A
6
Write proper program and output
Discuss the differences between a process and a thread.
3
10
7
5
5
10
10
10
(Book ID-B0832, Unit 1, Page No. 5)
SMU-DDE-Assignments-Scheme of Evaluation
A
5
Processes and Threads
In concurrent programming, there are two basic units of execution: processes
and threads. In the Java programming language, concurrent programming is
mostly concerned with threads. However, processes are also important.
A computer system normally has many active processes and threads. This is
true even in systems that only have a single execution core, and thus only have
one thread actually executing at any given moment. Processing time for a single
core is shared among processes and threads through an OS feature called time
slicing.
Processes
A process has a self-contained execution environment. A process generally has
a complete, private set of basic run-time resources; in particular, each process
has its own memory space.
Threads
Threads are sometimes called lightweight processes. Both processes and
threads provide an execution environment, but creating a new thread requires
fewer resources than creating a new process.
Threads exist within a process – every process has at least one. Threads share
the process's resources, including memory and open files. This makes for
efficient, but potentially problematic, communication.
10
5
*A-Answer
Note –Please provide keywords, short answer, specific terms, specific examples (wherever necessary)
***********