java programming for bsc it 4th sem kuvempu university

52
 Assignment: TB (COMPULSORY) 41 PART  A I. Say whether the following statements are true or false. 1) Definiteness is one of the properties of an algorithm. Ans:- TRUE 2) Graph is a linear data structure. Ans :- FALSE 3) A tree is a connected graph. Ans:- TRUE 4) The data structure used by recursion is stack. Ans :- TRUE 5) Queue works on the strategy “First in First out”. Ans :- TRUE II. Using suitable word or phrase fill up the blanks in the following sentences: 1) is the process of executing a correct program on data sets and measuring the time and space. Ans:- PROFILING 2) Tree is a data structure. Ans:-NON-LINEAR 3) For a graph with „nnumber of nodes the number of edges to form a tree is _____________ Ans: - n-1 4) “Last in First out” Data structure is referred to as Ans :- Stacks 5) A binary tree of depth „Khas maximum of _____________ number of nodes. Ans : - 2 k -1nodes,k>= 0 6) A is a graph without self loop and parallel edges. Ans. SIMPLE GRAPH 7) The two methods of searching are_____________ and_____________ Ans.:- SEQUENTIAL SEARCH AND BINARY SEARCH

Upload: usha-shaw

Post on 16-Jul-2015

4.358 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Java Programming for Bsc It 4th Sem kuvempu university

5/13/2018 Java Programming for Bsc It 4th Sem kuvempu university - slidepdf.com

http://slidepdf.com/reader/full/java-programming-for-bsc-it-4th-sem-kuvempu-university 1/52

 

Assignment: TB (COMPULSORY) 41

PART – A

I. Say whether the following statements are true or false.

1) Definiteness is one of the properties of an algorithm.Ans:- TRUE

2) Graph is a linear data structure.Ans :- FALSE

3) A tree is a connected graph.Ans:- TRUE

4) The data structure used by recursion is stack.

Ans :- TRUE

5) Queue works on the strategy “First in First out”.Ans :- TRUE

II. Using suitable word or phrase fill up the blanks in the following sentences:1) _____________is the process of executing a correct program on data sets andmeasuring the time and space.Ans:- PROFILING

2) Tree is a_____________data structure.Ans:-NON-LINEAR

3) For a graph with „n‟ number of nodes the number of edges to form a tree is _____________Ans: - n-1

4) “Last in First out” Data structure is referred to as _____________Ans :- Stacks

5) A binary tree of depth „K‟ has maximum of _____________number of nodes.Ans : - 2k -1nodes,k>= 0

6) A _____________is a graph without self loop and parallel edges.

Ans. SIMPLE GRAPH

7) The two methods of searching are_____________and_____________Ans.:- SEQUENTIAL SEARCH AND BINARY SEARCH

Page 2: Java Programming for Bsc It 4th Sem kuvempu university

5/13/2018 Java Programming for Bsc It 4th Sem kuvempu university - slidepdf.com

http://slidepdf.com/reader/full/java-programming-for-bsc-it-4th-sem-kuvempu-university 2/52

 

 

III. Write brief answers to the following questions:

1) Define algorithm. What are its properties?

Ans :- An algorithm is a set of instructions that provide step-by-step specifications to

perform a task.

Ex:-

Step by step procedure for display 10 natural numbers:-

1.  Set the value of counter to 1

2. 

Display counter3.  Increment counter by 1

4.  If counter <= 10, go to step 2

The preceding step -by -step procedure is an algorithm because it produces the

correct result in

A finite number of steps.

The properties of an algorithm are:

  Input: Specifies the data set that is applied to the algorithm to check its validity.

 

Output: Specifies the data set that is produced as a result of the algorithm execution.  Definiteness: Specifies that the instructions described in the algorithm should be well

defined and should not create any ambiguity.

  Termination: Specifies that the instructions described in the algorithm must contain a

proper termination condition.

  Effectiveness: Specifies that the algorithm take less time and less memory space

during its execution.

2) Give atleast four real life examples where we use stack operations.

Ans:- The real life examples of stacks are:

  Bangles in a hand: The bangles wore in a hand follow last-in-first-

out (LIFO) strategy of stack. The bangle that you wear first is thelast one to be taken out while removing all the bangles from thehand. The bangle that is worn last is the first one to be taken out.

Page 3: Java Programming for Bsc It 4th Sem kuvempu university

5/13/2018 Java Programming for Bsc It 4th Sem kuvempu university - slidepdf.com

http://slidepdf.com/reader/full/java-programming-for-bsc-it-4th-sem-kuvempu-university 3/52

 

  Same circumference circular rings in a pole: The rings having

same circumference placed into a pole also follow LIFO strategy.The topmost ring, which was the last to be placed in the pole, is thefirst one to be taken out.

  The bolts screwed to a single nut: When the bolts are screwed to asingle nut, the last screwed bolt is unscrewed first and the bolt thatwas screwed first is unscrewed in the last.

  Battery cells in a torch: The battery cells in a torch also follow thesame LIFO strategy of stack.

3) Differentiate full and complete binary trees.

Ans:- The following table lists the differences between complete binarytrees and full binary trees:

Complete binary trees Full binary trees

 All the nodes at the

 previous level are fully

accommodated before the

next level is accommodated.

 All levels are maximally

accommodated.

 Number of nodes at the last 

(n) level may or may not 

equal to 2n.

 Number of nodes at the last (n)

level is exactly equal to 2n.

 Leaf nodes may or may not be at the same level.

 All leaf nodes are at the samelevel.

 A complete binary tree may

or may not be full binary

tree.

 A full binary tree is always a

complete binary tree.

4) What are the demerits of recursion?

Ans:- Demerits of recursion are:

Many programming languages do not support recursion; hence,

recursive mathematical function is implemented using iterativemethods.

Even though mathematical functions can be easily implemented usingrecursion, it is always at the cost of execution time and memory space.

Page 4: Java Programming for Bsc It 4th Sem kuvempu university

5/13/2018 Java Programming for Bsc It 4th Sem kuvempu university - slidepdf.com

http://slidepdf.com/reader/full/java-programming-for-bsc-it-4th-sem-kuvempu-university 4/52

 

The recursive programs take considerably more storage and take more

time during processing.

PART - B

1. a) What are the characteristics of an algorithm? Describe with an example.Ans:- There are five Characteristics of every Algorithm: -

1)  INPUT

2)  OUTPUT

3)  DEFINITENESS

4) 

Effectiveness5)  Termination

Therefore, an algorithm can be defined as a sequence of definite and effective

instructions, which terminates with the production of correct output from the given input.

For EXAMPLE:- try to present the scenario of a man brushing his own teeth as an

algorithm as follows :-

1). Take the brush

2). Apply the paste

3). Start brushing

4). Rinse

5). Wash

6). Stop

If one goes through these 6 steps without being aware of the statement of the problem,

he could possibly feel that this is the algorithmfor claning a toilet. This is because of 

several ambiguities while comprehending every step. Step-1 may imply tooth brush,paint

brush, toilet brush, etc. uch an algorithm arises from the instruction of the above

algorithm step.thus every step has to be made unambiguous.An unambiguous step is

called definite instruction.

b) Write an algorithm to implement any three operations of a queue.Ans:- Algorithm: Isempty

Page 5: Java Programming for Bsc It 4th Sem kuvempu university

5/13/2018 Java Programming for Bsc It 4th Sem kuvempu university - slidepdf.com

http://slidepdf.com/reader/full/java-programming-for-bsc-it-4th-sem-kuvempu-university 5/52

 

Input: Q, Queue

Output: BooleanMethod:

If (F==0)Return (yes)ElseReturn (no)If endAlgorithm endsAlgorithm: IsfullInput: Q, QueueOutput: BooleanMethod:

If (R==SIZE)Return (yes)ElseReturn (no)If endAlgorithm ends

Algorithm: FrontInput: Q, QueueOutput: element in the frontMethod:

If (Isempty (Q))Print „no front element‟ 

ElseReturn (Q[F])If endAlgorithm ends 

2. a) Describe the two methods of representing a graph.Ans :- Two ways of representating Graph

DIRECTED GRAPH :- A graph that has an ordered pair of vertices, (x,y). Here , X is

the tail and y is the head of the edge. There is a path from vertex X to vertex Y. However

, a path from y to x may or may not exist . A path from y to x will be represented by e =

(y, x) . Therefore , e = (X , Y) and e = (Y , X) are to seprate edges for a directed graph.

V2V1

V3

V5

V4

Page 6: Java Programming for Bsc It 4th Sem kuvempu university

5/13/2018 Java Programming for Bsc It 4th Sem kuvempu university - slidepdf.com

http://slidepdf.com/reader/full/java-programming-for-bsc-it-4th-sem-kuvempu-university 6/52

 

DIRECTED GRAPH

The graph contains five vertices,namely,v1,v2,v3,v4, and v5. The graph contains four

directed edges,namely,(v1,v2) , (v2,v3) , (v4,v3) , (v4,v1) , (v4,v5) , and (v5,v1).

UNDIRECTED GRAPH :- A graph that has an unordered pair of vertices

representing an edge. This means that if e = (v ,w) ,then (v, w) and (w ,v) are considered

as the same edge.

For EX :-

UNDIRECTED GRAPH

b) Design an algorithm to generate all prime numbers between 10 and 20.Ans.:- Algorithm: Primality_Testing (Second approach)Input : between 10 & 20 , number

flag, test conditionOutput : flag updatedMethodflag = 0for(i=2 to square_root(n) in steps of +1 and flag = 0)if( n % i = 0) // n mod i

flag = 1end_if end-forif(flag = 0)display „Number is prime‟ else

display „Number is not prime‟ end_if Algorithm ends3. a) Trace out the algorithm Max Min on a data set containing atleast 8 elements.

v1

V4 V3

V2

Page 7: Java Programming for Bsc It 4th Sem kuvempu university

5/13/2018 Java Programming for Bsc It 4th Sem kuvempu university - slidepdf.com

http://slidepdf.com/reader/full/java-programming-for-bsc-it-4th-sem-kuvempu-university 7/52

 

Ans:- Steps to perform MaxMin on a data set (2,4,6,3,8,1,9,7) are:

(2,4,6,3) (8,1,9,7)

((2,4)(6,3)) ((8,1)(9,7))

In sublist (4,6), max is 6 and min is 4. In sublist (8,9), max is 9 and minis 8.

Comparing max and min values of sublist (2,4) and sublist (6,3), valueof max is 6 and min is 2.

Therefore, for sublist (2,4,6,3) max is 6 and min is 2.

Similarly, comparing max and min values of sublist (8,1) and sublist(9,7), value of max is 9 and min is 1.

Therefore, for sublist (8,1,9,7) max is 9 and min is 1.

Finally, comparing max and min values of sublist (2,4,6,3) and sublist(8,1,9,7), value of max is 9 and min is 1.

b) Design an algorithm to sort the elements using merge sort.Ans:- Algoritm : MERGESOt

Input : low,high,the lower and upper limits of the list to be sorted

A,the list of elements

Output : A, Sorted list

Method:

If (low < high)

Mid (low +high )/2

MERGESORT(low,mid)

MERGESORT(mid,high)

MERGE(A,low,mid,high)

Ifend

Algorithm ends

4. What are preorder, Inorder, postorder traversals of a binary tree? Design recursionalgorithms to implement them and explain with the help of an example.

Page 8: Java Programming for Bsc It 4th Sem kuvempu university

5/13/2018 Java Programming for Bsc It 4th Sem kuvempu university - slidepdf.com

http://slidepdf.com/reader/full/java-programming-for-bsc-it-4th-sem-kuvempu-university 8/52

 

Ans:- Traversal is the most important operation done on a binary tree. Traversal is the

process of visiting the verticesof the tree in a systematic order. Systematic means thatevery time the tree is traversed it should yield the same result.

PRE-ORDER TRAVERSAL

In this traversal , the nodes are visited in the order of root, Left

child and then right child ,i.e.,

1)  Visit the root node first.

2)  Go to the first left sub-tree.

3)  After the completion of the left sub-tree, Go to the right sub-tree.

Here , the lleaf nodes represent the stopping criteria. We go to the sibling

sub-tree after the traversal of a sub tree.

IN-ORDER Traversal

In this traversal , the nodes are visited in the order of the left child,root and then right

child.i.e., the left sub-tree is traversed first, then the root is visited and then the right

sub-tree is traversed. Here also,the left nodes denotes the stopping criteria.

POST-ORDER Traversal

In this traversal, the nodes are visited in the order of left child,right child and then root.

i.e.,the left sub-tree is traversed first, then the sibling is traversed next.the root is visited

last.

The recursion algorithm

Algorithm: Pre-order TraversalInput: bt, address of the root nodeOutput: Preorder sequenceMethod:if(bt != NULL){Display([bt].data)Pre-order Traversal([bt].Lchild)Pre-order Traversal([bt].Rchild)

}Algorithm ends.Algorithm: In-order TraversalInput: bt, address of the root node

Page 9: Java Programming for Bsc It 4th Sem kuvempu university

5/13/2018 Java Programming for Bsc It 4th Sem kuvempu university - slidepdf.com

http://slidepdf.com/reader/full/java-programming-for-bsc-it-4th-sem-kuvempu-university 9/52

 

Output: Inorder sequence

Method:if(bt != NULL){In-order Traversal([bt].Lchild)Display([bt].data)In-order Traversal([bt].Rchild)}Algorithm ends.

Algorithm: Post-order TraversalInput: bt, address of the root nodeOutput: Postorder sequenceMethod:if(bt != NULL){Post-order Traversal([bt].Lchild)Post-order Traversal([bt].Rchild)Display([bt].data)}Algorithm ends.

5. a) What is binary search? Develop a recursive algorithm for binary search.Ans:- Binary search is necessary to have the vector in an alphabetical or numerically

increasing order .

Consider an example where we have to search for the name Steve in a tlephone

directory that is sorted alphabetically . in this case ,we donot search for the name

sequentially .instead, we open the telephone directory at the middle to open the telephone

directory at the middle to determeine which half contains the name.

Recursive algorithm for binary search

Algorithm : Binary search

Input: A,vector of n elements

K,earch elementsOutput : low-index of k 

Method :

Page 10: Java Programming for Bsc It 4th Sem kuvempu university

5/13/2018 Java Programming for Bsc It 4th Sem kuvempu university - slidepdf.com

http://slidepdf.com/reader/full/java-programming-for-bsc-it-4th-sem-kuvempu-university 10/52

 

Low = l, high = n

While(low <= high-1)

{

Mid = (low + high)2

If(k<a[mid]])

High = mid

Else

Low = mid

If end

}

While end

If (k= A[low])

{

Write (“ search successful”) 

Write( k is at location low)

Exit();

}

Else

Write(search unsuccessful);

If end;

Algorithm ends;

b) What are the two methods of representing a binary tree?Ans:- The two methods of representing binary tree are:-

Page 11: Java Programming for Bsc It 4th Sem kuvempu university

5/13/2018 Java Programming for Bsc It 4th Sem kuvempu university - slidepdf.com

http://slidepdf.com/reader/full/java-programming-for-bsc-it-4th-sem-kuvempu-university 11/52

 

  Static allocation and,

 

Dynamic allocation

In static allocation ,we have two ways of representing the binary tree.one is through the

use of adjacency matrices and other through the use of single represention dimensional

array representation.

6. a) Design an algorithm to check whether a given string is a palindrome or not.

Ans :- Algorithm: check whether the string is a palindrome or not

Input: string, flag

Output: string is a palindrome

Method:

count = 0while (the next character ch in the string is not empty)

a(count) = chcount = count+1

end whilehalf = count/2palin = true

for (i=1 to half in steps of 1 and j=count to half in steps of  – 1 do)

if (a (i)! =a (j))palin = falsebreak 

end if if (palin = true)

Display 'String is a palindrome'else

Display 'String is not a palindrome'end if 

end for

Algorithm ends

b) Trace out the algorithm quick sort on the data set {1,5,7,19,15,8,9, 10}.

Ans :- 

{(1),5,7,19,15,8,9, 10}

{(1),5,7,15,19,8,9, 10}

{1,5,7,(15),10,8,9, 19}

Page 12: Java Programming for Bsc It 4th Sem kuvempu university

5/13/2018 Java Programming for Bsc It 4th Sem kuvempu university - slidepdf.com

http://slidepdf.com/reader/full/java-programming-for-bsc-it-4th-sem-kuvempu-university 12/52

 

{1,5,7,(10),15,8,9, 19}

{1,5,7,(10),8,15,9, 19}

{1,5,7,8,10,15,9, 19}

{1,5,7,8,10,9,15, 19}

{1,5,7,8,9,10,15, 19}

7. a) What is validation and testing of algorithms?

Ans :- Validating:- Once an algorithm has been devised it become necessary to show thatit works it computer the correct to all possible, legal input. One simply way is to codeinto a program. However converting the algorithm into program is a time consuming

process. Hence,it is essential to be reasonably sure about the effectiveness of thealgorithm beforeit is coded. This process, at the algorithm level,is called"validation".Several mathematical and other empirical method of validation are available. Providingthe validation of an algorithm is a fairly complex process and most often a completetheoritical validation though desirable, mey not be provided. Alternately, algorithmsegment,which have been proved elsewhere may be used and the overall workingalgorithm may be empirically validated for several test cases.And, The process of measuring the effectiveness of an algorithm before it is coded to know the algorithm iscorrect for every possible input.This process is called validation.

Example :-This article describes the algorithms for validating bank routing numbers and credit cardnumber using

the checksum built into the number. While they differ in how they are generated, thetechnique used for both is similar.

Testing : - The test of an algorithm is that the program based on the algorithm should run

satisfactorily. Testing a program really involves two phases a) debugging and b)

Profiling. Debugging is the process of executing programs with sample datasets to

determine if the results obtained are satisfactory.When unsatisfactory results are

generated ,suitable changes are made in the program to get the desired results. On the

other hand,profiling or performance measurement is the process of executing a correct

program on different data sets to mesure the time and space that it takes to compute the

results.

b) Explain the terms with examplesi) Finite graph

Page 13: Java Programming for Bsc It 4th Sem kuvempu university

5/13/2018 Java Programming for Bsc It 4th Sem kuvempu university - slidepdf.com

http://slidepdf.com/reader/full/java-programming-for-bsc-it-4th-sem-kuvempu-university 13/52

 

Ans:-A graph with a finite number of vertices as well as finite number of edges is called a

finite graph.

Finite graph

ii) Isolated and pendent vertices

Ans :- A vertex having no incident edge is called an isolated vertex. Vertex v4 and v7 areisolated vertices(in fig). A vertex of degree one is called a pendent vertex or an endvertex. Vertex v3 is pendent vertex (in fig).

V2 

V4 V3

V7 

V1 v5

V6

Graph ontaining isolated vertices and pendent vertexiii) NULL graph

in the definition of a graph G = ( V , E) it is possible for the edge set E to beempty. Such a graph , without any edges, is called a null graph.

V2 

V4 V3

V7 

V1 v5

V6

iv) Path.Ans.:- if a walk has the restriction of no repetition of vertices and no edge is retraced it iscalled a path.8. Write short notes on :a) Debugging

V2V1

V3

V5

V4

Page 14: Java Programming for Bsc It 4th Sem kuvempu university

5/13/2018 Java Programming for Bsc It 4th Sem kuvempu university - slidepdf.com

http://slidepdf.com/reader/full/java-programming-for-bsc-it-4th-sem-kuvempu-university 14/52

 

Ans.- Debugging is the process of executing programs with sample datasets to determine

if the results obtained are satisfactory. When unsatisfactory results are generated, suitablechanges are made in the program to get the desired results. On the other hand, profiling orperformance measurement is the process of executing a correct program on different datasets to measure the time and space that it takes to compute the results.

b) The need for recursionAns.:- The need of recursion is :

1) Mathematical functions such as factorial and fibonaci series generation can beeasily implemented using recursion than iteration.

2) in iterative techniques looping of statement is very much necessary..c) Incidence matrix.Ans.:- The incidence matrix contains only two elements , o and 1. Such a matrix is calleda binary matrix or a (0,1) matrix. Since every edge is incident on exactly two vertices,each column of a has exactly two 1.The number of 1‟ in each now equals the degree of the corresponding vertex. A row with all 0‟ , therefore ,represents an isolated vertex.Parallel edges in a graph produce identical columns in its incidence matrix.

Assignment: TB (Compulsory) 42

PART-A1. How platform independence is achieved in JAVA ?

Ans.:- Java is known as platform-neutral language because Java's byte codes are designedto be read, interpreted, and executed in exactly the same manner on any computerhardware or operating system that supports a Java run-time.

2. List any three features of JAVA.Ans.:- The Features of JAVA

1) Simple2) Object-Oriented3) Distributed

3. What is Java C, Javadoc and Jdbc?Ans. :- Java C – JavaC is a compiler translates java source code to byte code.

Javadoc – Javadoc is used for creates html format documentation from java

source file.Jdbc - A programming interface that lets Java applications access a database viathe SQL language. Since Java interpreters (Java Virtual Machines) are available for allmajor client platforms, this allows a platform-independent database application to be

Page 15: Java Programming for Bsc It 4th Sem kuvempu university

5/13/2018 Java Programming for Bsc It 4th Sem kuvempu university - slidepdf.com

http://slidepdf.com/reader/full/java-programming-for-bsc-it-4th-sem-kuvempu-university 15/52

 

written.

4. List different features of OOP.Ans :- The features of OOP.

1) Objects and classes2) Abstraction3) Encapsulation4) Information hiding5) Inheritance6) Polymorphism

5. Name different types of Java tokens.Ans. :- The different types of Java tokens are :-

1) Reserved Keywords2) Identifiers3) Literals4) Operators

6. What is the task of the main method in Java program ?

Ans.:- After we specify the keywords for declaring the main() method, you specify aString array as parameter of the main() method. The String array represents commandline arguments. It is compulsory for a user to specify the parameter to the main() methodin all Java programs unlike in C and C++.

For example,

Class class1

{

public static void main (String args[])

{

System.out.println ("Hello")

}

}

7. Why can‟t we use a keyword as a variable name ?

Ans.:- Keywords are an essential part of a language definition. They implement specificfeatures of the language. Java language has reserved 60 words as keywords. These

keywords have specific meaning in Java, so you cannot use them as names for variables.

8. Why main method in Java is declared as static ?

Page 16: Java Programming for Bsc It 4th Sem kuvempu university

5/13/2018 Java Programming for Bsc It 4th Sem kuvempu university - slidepdf.com

http://slidepdf.com/reader/full/java-programming-for-bsc-it-4th-sem-kuvempu-university 16/52

 

Ans.:- The keyword static helps to specify that the main() method can be called without

instantiating an object of a class. This is necessary because the main() method is called bythe Java interpreter before any objects are created.

public static void main (String args[])

{//code}

After specifying the keyword static, you specify the void keyword. This keywordindicates to the compiler that, the main() method does not return a value.

9. Write an equivalence of switch statement and if statement.Ans.:-equivalence of switch statement is if and the equivalence of if statement is if else.10. Constructor is_____________.Ans.:- used to initialize the objects of the class and has the same name as that of its class.

PART - B1. a) What is inheritance and how one can achieve code reusability? Explainwith an example.Ans.:-Inheritance in object oriented programming means that a class of objects caninherit properties from another class of objects. When Inheritance occurs, one class isthen referred to as the „parent class‟ or super class‟ or „base class‟. 

Inheritance is an important concept since it allows reuse of class definition

without requiring major code changes, inheritance can mean just reusing code , or canmean that you have used a whole class of object with all its variables and functionsFor ex, the bike is a part of the class two wheelers, which is again a part of the vehicle as:

Vehicle

Attributes:

Two Wheeler Four Wheeler

Attributes:

Bike

Attributes:

Scooter

Attributes:

Car

Attributes

Van

Attributes

Page 17: Java Programming for Bsc It 4th Sem kuvempu university

5/13/2018 Java Programming for Bsc It 4th Sem kuvempu university - slidepdf.com

http://slidepdf.com/reader/full/java-programming-for-bsc-it-4th-sem-kuvempu-university 17/52

 

 

b) What is a class? How does it accomplish data hiding? Explain with example.

Ans.:- Class is a template that defines a particular type of object. Classes contain all thefeatures of a particular set of objects. We can use the class definition to create objects of 

that of class type, that is, to create objects that incorporate all the features belonging tothat class.

Each object of the class will have its own copy of each of the instance variables thatappear in the class definition. Each object will have its own values for each instancevariable. The name 'instance variable' originates from the fact that an object is an'instance' or an occurrence of a class and the values stored in the instance variables for theobject differentiate the object from others of the same class type. An instance variable isdeclared within the class definition in the usual way, with a type name and a variablename, and can have an initial value specified.

A given class will only have one copy of each of its class variables, and these will beshared between all the objects of the class. The class variables exist even if no objects of the class have been created. They belong to the class, and they can be referenced by any

object or class, and not just instances of that class. 

Ex:- we might define a motorcycle class that describes the features of all motorcycles .the motorcycle class serves as an abstract model for the concept of a motorcycle-tointeract with each type of motorcycle,we should have a concrete instance of thatmotorcycle.

2. a) Compare in terms of their functions and semantics the following pairs of statements:i) do while and whileAns.:- The difference between the do-while statement and the while statement is that inthe while statement, the loop body is executed only when the condition stated in thestatement is true. In the do-while loop, the loop body is executed at least once, regardlessof the condition evaluating to true or false. The while loop is also called the top tested

loop whereas the do-while loop is also called the bottom tested loop.

ii) while and for

Page 18: Java Programming for Bsc It 4th Sem kuvempu university

5/13/2018 Java Programming for Bsc It 4th Sem kuvempu university - slidepdf.com

http://slidepdf.com/reader/full/java-programming-for-bsc-it-4th-sem-kuvempu-university 18/52

 

Ans.:- In the for loop, three sections, initialization, test condition and

increment/decrement are placed in the same line whereas in the while loop, all threesections are placed in three different places in a program. In the for loop, more than onevariable can be initialized, tested and incremented at a time.

iii) nested if and switch

Ans.:-The difference between nested if and switch statement is

if allows complex expressions in the condition while switch wants a constant we

can't accidentally forget the break between ifs but you can forget the else (especially

during cut'n'paste)

switch is usually more compact than lots of nested if else and therefore, more

readable

If you omit the break between two switch cases, you can fall through to the next case

in many C-like languages. With if else you'd need a go to (which is not very nice to

your readers ... if the language supports go to at all.

iv) break and continue.

Ans.:- The continue statement stops the current iteration of a loop and immediately startsthe next iteration of the same loop. When the current iteration of a loop stops, the

statements after the continue statement in the loop are not executed. The break statementimmediately terminates the loop, bypassing the conditional expression and any remainingcode in the body of the loop. When a break statement is encountered inside the loop, theloop is terminated and program control resumes the next statement following the loop.

b) Write a program to find sum of the following harmonic series for a given valueof n 1+ 1/2 + 1/3 + . . . .+ 1/n.

Ans.:- public class Series

{

double total;

public void calculate(int n)

{

for(double ctr=1;ctr<=n;ctr++)

Page 19: Java Programming for Bsc It 4th Sem kuvempu university

5/13/2018 Java Programming for Bsc It 4th Sem kuvempu university - slidepdf.com

http://slidepdf.com/reader/full/java-programming-for-bsc-it-4th-sem-kuvempu-university 19/52

 

{

total=total+1/ctr;

}

System.out.println("Sum of harmonic series: "+total);

}

public static void main(String a[])

{

Series object=new Series();

int num=Integer.parseInt(a[0]);

object.calculate(num);

}

}

3. a) Explain different data types in Java with example.Ans.:- DATA TYPES IN JAVA

byte: It is the smallest integer type. This is a signed 8-bit type and has a rangefrom -128 to 127. For example, the following declaration declares two variables B and Cof type byte.byte b,c;b =2;c = -114;

short: It is a signed 16-bit type and has a range from -32,768 to 32,767. For example, thefollowing declaration declares variable K of type short.short k;k = 2;int: It is a signed 32-bit type and has a range from -2,147,483,648 to 2,147,483,647.For example,int x = 10;int j = 98;long: This is signed 64-bit type and has a range from -263 to 263 -1.For example,long ds = 1000;long se;se =ds * 24 * 60 * 60;

double: It uses 64 bits to store a value.For example,double P, R;P = 10.8;

Page 20: Java Programming for Bsc It 4th Sem kuvempu university

5/13/2018 Java Programming for Bsc It 4th Sem kuvempu university - slidepdf.com

http://slidepdf.com/reader/full/java-programming-for-bsc-it-4th-sem-kuvempu-university 20/52

 

R =3.14215;

float: It uses 32 bits to store a value.For example,float x;x = -1111;int : It uses 32 bits to store a value.For example,Int score;Score=90;char: this data type is used to store characters. It is 16-bit type and has a range from 0 to65,536.For example,char c1,c2;c1 =84;c2 ='g';boolean: it can have only one of two possible values, true or false.For example,boolean flag;flag= false;

b) Describe the structure of a typical Java program.

Ans. :- :- A Java program may contain many classes of which only one class defines amain method. Classes contain data members and methods. Methods of a class operate onthe data members of the class. Methods may contain data type declarations andexecutable statements. To write a Java program, we first define classes and then put themtogether.

A Java program may contain one or more sections as shown in the following figure:

Documentation Section Suggested

Package Statement Optional

Import Statements Optional

Interface Statements Optional

Class Definitions Essential

Main Method class{

Main Method Definition

}

Essential

Page 21: Java Programming for Bsc It 4th Sem kuvempu university

5/13/2018 Java Programming for Bsc It 4th Sem kuvempu university - slidepdf.com

http://slidepdf.com/reader/full/java-programming-for-bsc-it-4th-sem-kuvempu-university 21/52

 

General Structure Of a Java program

Documentation Section

The documentation section comprises a set of comment lines giving thename of the program, the author and other details. Java also uses thecomment /**...*/ known as documentation comment.

Package Statement

The first statement allowed in a Java file is a package statement. Thisstatement declares a package name and informs the compiler that theclasses defined here belong to this package.

Example: package student;

Import Statement

The next thing after a package statement (but before any classdefinitions) may be a number of import statements. This is similar to the#include statement in C++. Example:

import student.test;

This statement instructs the interpreter to load the test class contained inthe package student.

Interface Statements

An interface is like a class but includes a group of method declarations.

This is also an optional section and is used only when we wish toimplement the multiple inheritance feature in the program.

Class Definitions

A Java program may contain multiple class definitions. Classes are theprimary and essential elements of a Java program.

4. a) What is JVM ? How does it help to achieve platform independence? If JVM isavailable for windows then can we run program written on Unix platform ?Comment.

Ans.:-Java compiler produces an intermediate code known as byte code for a machinethat does not exist . this machine is called JAVA VIRTUAL MACHINE (JVM). . Java is

known as platform-neutral language because Java's byte codes are designed to be read,interpreted, and executed in exactly the same manner on any computer hardware oroperating system that supports a Java run-time.

Page 22: Java Programming for Bsc It 4th Sem kuvempu university

5/13/2018 Java Programming for Bsc It 4th Sem kuvempu university - slidepdf.com

http://slidepdf.com/reader/full/java-programming-for-bsc-it-4th-sem-kuvempu-university 22/52

 

Yes. One of the fundamental principles of Java is "write once, run anywhere." This

means that Java source code can run on any platform for which a JVM exists, regardlessof where the original code was developed

b) How are data and method organized in an object oriented program ? Illustratethe same for car object.Ans.:- In an object-oriented program, a set of variables and functions used to describe anobject constitutes a "class".A class defines the structure and behavior (data and method) that will be shared by a setof objects. Each object of a given class contains the structure and behavior defined by theclass, as if it were stamped out of a mould in the shape of a class. A class is a logicalconstruct. An object has physical reality. When we create a class, you will specify thecode and data that will constitute that class. Collectively, these elements are called themembers of the class. Specifically, the data defined by the class are referred to asmember variables or instance variables. The code that operates on that data is referred toas member methods or just methods, which define the use of the member variables.5. a) Distinguish between the following terms:i) Dynamic binding and message passing.

Ans.:- Dynamic binding in java is the mechanism by which compilercannot determine which method implementation to use in advance.Based on the class of the object, the runtime system selects theappropriate method at runtime. Dynamic binding is also neededwhen the compiler determines that there is more than one possiblemethod that can be executed by a particular call.Java's program units, classes, are loaded dynamically (when needed)

by the Java run-time system. Loaded classes are then dynamicallylinked with existing classes to form an integrated unit. The lengthylink-and-load step required by third-generation programminglanguages is eliminated.Message Passing: In an object based world the only way foranything to happen is by objects communicating with each other andacting on the results. This communication is called message passingand involves one object sending a message to another and (possibly)receiving a result.

ii) Inheritance and polymorphism.Ans.:- Inheritance in object-oriented programming means that a class of objects caninherit properties from another class of objects. When inheritance occurs, one class is

then referred as the 'parent class' or 'super class' or 'base class'. In turn, these serve as apattern for a 'derived class' or 'subclass'.

Page 23: Java Programming for Bsc It 4th Sem kuvempu university

5/13/2018 Java Programming for Bsc It 4th Sem kuvempu university - slidepdf.com

http://slidepdf.com/reader/full/java-programming-for-bsc-it-4th-sem-kuvempu-university 23/52

 

Inheritance is an important concept since it allows reuse of class definition without

requiring major code changes. Inheritance can mean just reusing code, or can mean thatyou have used a whole class of object with all its variables and functions.Polymorphism: It is a key concept in object-oriented programming. Poly means many,morph means change (or 'form').Polymorphism is simply a name given to an action that is performed by similar objects.Polymorphism allows a common data-gathering message to be sent to each class andallows each subclass object to respond to a message format in an appropriate manner toits own properties. Polymorphism encourages something we call 'extendibility'. In otherwords, an object or a class can have its uses extended.

b) What are the difference between C and Java ?How Java and C++ are similar?Ans.:-6. a) Define programming. What are the types of programming? Explain.Ans.:- Programming:- a programming is a specific set of ordered operations for acomputer to perform .

UNSTRUCTURED PROGRAMMINGIn an unstructured programming the main program directly operates on global data.

PROCEDURAL PROGRAMMINGWith procedural programming we are able to combine returning sequence of statementsinto one single place . a procedure call is used to invoke the procedure.

MODULAR PROGRAMMINGWith modular programming procedures of a common functionality are grouped togetherinto separate modules. A program therefore no longer consists of only one single part.

OBJECT-ORIENTED PROGRAMMINGIn object oriented programming, a complex system is decomposed in accordance to the

key abstractions of the problem.It is a method of implementation in which programs are organized as co-operativecollection of objects, each of which representation an instance of some class and whoseclasses all members of a hierarchy of classes united in inheritance relationships.

b) Explain bitwise operators in Java with example.Ans.:- BITWISE OPERATORS

SHIFT AND LOGICAL OPERATORSA shift operator allows you to perform bit manipulation on data.OPERATOR USE OPERATION>> Op1 >> op2 Shift bits of op1 right by distance op2

<< Op1 << op2 Shift bits of op1 left by distance op2>>> Op1>>> op2 Shift bits of op1 right by distance op2

Each shift operator shifts the bits of the left-hand operand over by the number of positions indicated by the right- hand operand.Ex. – 13 >> 1

Page 24: Java Programming for Bsc It 4th Sem kuvempu university

5/13/2018 Java Programming for Bsc It 4th Sem kuvempu university - slidepdf.com

http://slidepdf.com/reader/full/java-programming-for-bsc-it-4th-sem-kuvempu-university 24/52

 

The binary representation of the number 13 is 1101. The result of 

the shift operations is 1101 shifted to the right by one position -1106 or 6 in decimal.The java programming language also provides these four operators that perform logicalfunctions on their operands :-OPERATOR USE OPERATION

& Op1 & op2 Bitwise and| Op1 | op2 Bitwise or

^ Op1 ^ op2 Bitwise x or~ Op1 ~ op2 Bitwise complementThe & operation performs the logical “and” function on each parallel pair of bits in eachoperand . the “and” function sets the resulting bit of 1 if both operands are 1 . Op1 Op2 RESULT0 0 0

0 0 01 0 01 1 1Suppose we were to “and” the values 12 and 13 

12 & 13The result of this operation is 12. Because the binary representation of 13 is 1101. The

“and” function sets the resulting bit to 1 if both to 1 if both operand bits are 1, otherwise,the resulting bit is 0.

7. a) List and explain different types of loops in Java.Ans. :- Loops in java

  While loop

  Do loop

 

For loop , continue and break statementTHE WHILE LOOP

The while statement contains a condition and a loop body. the condition is enclosedwithin parentheses.

All the variables used in the condition of the while statement must be initialized beforethe while loop. The values of the variables used in the condition must be changed in theloop body. Otherwise, the condition may always remain true and the loop may neverterminate.

 

Syntax:

While (test condition)

{

Body of the loop

True

Conditio

nStatement

Page 25: Java Programming for Bsc It 4th Sem kuvempu university

5/13/2018 Java Programming for Bsc It 4th Sem kuvempu university - slidepdf.com

http://slidepdf.com/reader/full/java-programming-for-bsc-it-4th-sem-kuvempu-university 25/52

 

Ex.-

Class numbers{

Public state void main(String args[]){

Int n = 0 ;Int num = 5;While (n <= num)

{System.out.println(n);N++

}}}

DO STATEMENTSimilar to the while statement, the do-while statement is a lopp statement provided by

 java. The statement helps to perform certain repetitive actions depending on a condition.The major difference between the do-while statement and the while statement is that in

the while statement, the loop body is executed only when the condition stated in thestatement is true.We can use the do-while loop in situations where an action must be performed at leastonce without evaluating the condition.

Program to print the numbers from 1 to 5

Class numbers{

Public static void main (string args[]){

 

Syntax:

While (test condition)

{ do

Body of the loop

};

Conditio

n

 

Statement

Page 26: Java Programming for Bsc It 4th Sem kuvempu university

5/13/2018 Java Programming for Bsc It 4th Sem kuvempu university - slidepdf.com

http://slidepdf.com/reader/full/java-programming-for-bsc-it-4th-sem-kuvempu-university 26/52

 

Int n=0;

Int num = 5;Do

{System.out.println(n);N++;

}While(n<=5);}}FOR STATEMENTSTo manage iterative actions, java provides the for statement as an efficient alternative tothe while statement. The statement creates to loop in which a set of statements isrepeatedly executed until the specified condition becomes false.The syntax of the for statement isFor(initialization expression; test condition; update expressions){Statement1;Statement2;}The for statement starts with the for keyword.

b) What is polymorphism? Explain method overriding with example and provethat it is a polymorphism.Ans.:- :- Polymorphism (from the Greek, meaning "many forms") is a feature that allowsone interface to be used for a general class of actions. The specific action is determined

by the exact nature of the situation.Ex.- a stack (which is a last-in, first-out list). You might have a program that requiresthree types of stacks. One stack is used for integer values, one for floating-point values,and one for characters.METHOD OVERRIDINGIn the class hierarchy, when a method in a subclass has the same name and type signatureas methodin the superclass, then the method in the subclass is said to override the method insuperclass.class Book { //super class definedString name = “JAVA PROGRAMMING” ; int id = “34567”; void show ( ) {

System.out.println( “Book name is “ +name);System.out.println( “Book id is “ +id); }}

Page 27: Java Programming for Bsc It 4th Sem kuvempu university

5/13/2018 Java Programming for Bsc It 4th Sem kuvempu university - slidepdf.com

http://slidepdf.com/reader/full/java-programming-for-bsc-it-4th-sem-kuvempu-university 27/52

 

Save this file as book.java and compile. This is our Base Class

class Book1 extends Book { // This is the subclassString author = “micheal janson”; void show ( ) {System.out.println( “Book name is “ +name);System.out.println( “Book id is “ +id); System.out.println( “The author name is “ +author); }public static void main(String args[ ] ) {Book1 x = new Book1( );x.show();}}

8. a) What is a parameterized constructor? Explain its usage with an example.Ans:- A parameterized constructor in java is just a constructor which take some kind of parameter (variable) when is invoked. For example.

class MyClass {

 //this is a normal constructorpublic MyClass(){

 //do something}

 //this is a parameterized constructor

public MyClass(int var){ //do something}

 //this is another parameterized constructorpublic MyClass(String var, Integer var2){

 //do something}

}

b) Explain the methods(i) Trim

Ans. :- The trim method returns a copy of the invoking string from which any leadingand trailing white space has been removed. It has the general formString trim ( );class altStr{

Page 28: Java Programming for Bsc It 4th Sem kuvempu university

5/13/2018 Java Programming for Bsc It 4th Sem kuvempu university - slidepdf.com

http://slidepdf.com/reader/full/java-programming-for-bsc-it-4th-sem-kuvempu-university 28/52

 

public static void main (String args[ ]) {

String str = "Hello";String str2 = "Java";str = str.toUpperCase();str2 = str2.toLowerCase();System.out.println (str); // HELLOSystem.out.println (str2);// javastr = str.concat(str2); // str now equals "HELLO java"System.out.println (str);str = str.trim(); // str now equals "HELLOjava"System.out.println (str);str = str.substring (5,str.length()); // str = "java"System.out.println (str);str = str.replace ('a', 'i'); // str = "jivi"System.out.println (str);}

}

ii) substringThe subString method is used to create new instances of the class String from existinginstances. The new string is specified by giving the required index range within theexisting string.String substring(int startIndex)This returns the sub string that starts at startIndex and runs to the end of the invokingstring.String substring(int start Index, int endIndex)

This returns the substring that starts at startindex and runs through endIndex-1;

iii) lengthThe length of a string is the number of characters that it contains. To obtain this value calla length method.

int length();class strCmp {public static void main (String args[ ]) {String str = "Hello";String str2 = "Java";System.out.println (str.equals(str2)); // falseSystem.out.println (str.compareTo(str2)); // a negative number,i.e. str is less than str2

System.out.println (str.charAt(0)); // H, i.e. char is position 0System.out.println (str.length() + str2.length()); // 5 + 4 = 9}}

Page 29: Java Programming for Bsc It 4th Sem kuvempu university

5/13/2018 Java Programming for Bsc It 4th Sem kuvempu university - slidepdf.com

http://slidepdf.com/reader/full/java-programming-for-bsc-it-4th-sem-kuvempu-university 29/52

 

 

Assignment: TB (Compulsory) 43

PART - A

1. What are the different standard given by POSIX ? What is POSIX ?Ans. :- The different standard given by POSIX are:-

  POSIX.1  POSIX.1B  POSIX.1C  POSIX.2

  POSIX:2001  POSIX:2004  POSIX:2008

POSIX is the Portable Operating System Interface, the open operatinginterface standard accepted world-wide. It is produced by IEEE and recognizedby ISO and ANSI.2. On which variable terminal setting is done ? Name any three terminal settingkeys.Ans.:- Using STTY

Three terminal setting key

quit, kill, erase, ...

The environment variable TERM is used to identify the type of terminal (or terminalemulator) to the curses library and programs that use the curses library to display text. Itis also associated with the TERMINFO and (in archaic systems) TERMCAP environmentvariables3. Explain key features of UNIX.Ans. :- The UNIX system is supported by the file and the process. Directories anddevices are treated as files and there are many text manipulation tools to edit these files.When a file is executed as a program, it is called a process. There are tools to controlprocesses like sending a processes into background or even terminating it.

Unix is a multitasking operating system, which allows the computer to run severalprograms at the same time. By going quickly from one task to another and performing alittle bit of each task every time, the operating system gives an impression of doing manythings at the same time. Unix uses this technique of time-sharing. Unix is also able to

.

Page 30: Java Programming for Bsc It 4th Sem kuvempu university

5/13/2018 Java Programming for Bsc It 4th Sem kuvempu university - slidepdf.com

http://slidepdf.com/reader/full/java-programming-for-bsc-it-4th-sem-kuvempu-university 30/52

 

interact with more than one user at a time. This feature of Unix makes it a multitasking

system.4. What is script command, with command explain how to create script file of asession?5. What happens if a directory permission charged?Ans.- Every time a file or a directory is created, default permissions are established

for it. These default permissions are initially assigned either by the operating

system or the program being run. Setting default permissions saves us the

trouble of specifying permission codes explicitly every time a file or directory is

created. The operating system assigns the default permission values of 777 for

executable files and 666

for all other files.

To put further restrictions on the permissions assigned by a program when it

creates a file or directory, a user mask is specified with the umask command.

The user mask is a numeric value that determines the access permissions when a

file or directory is created. Consequently, when a file or directory is created, its

permissions are set to the permissions specified by the creating program minus

the permission values denied by the umask value.

Example

The command umask without arguments gives the octal value of the user mask.

$ umask 

022

6. How do you yank and paste lines?Ans. :- The command 'Y' or 'yy' copies (yanks) one or more lines. To copy one line,two lines, 10 lines, and all lines to the end of the file, respectively:

Y2Y10Y

yG

To paste the text contained in the buffer above (uppercase P) or below the currentcursor position (lowercase p), respectively:

Page 31: Java Programming for Bsc It 4th Sem kuvempu university

5/13/2018 Java Programming for Bsc It 4th Sem kuvempu university - slidepdf.com

http://slidepdf.com/reader/full/java-programming-for-bsc-it-4th-sem-kuvempu-university 31/52

 

P

pIt is also possible to yank text within a line. The following commands yank textfrom the current cursor position to the end of the word and the end of the line,respectively:ywy$

The same commands paste the text within a line. Lower case p pastes after thecursor position and upper case P pastes before.

Paste will also work with deleted text, either lines or parts of lines. Be careful notto execute any other commands prior to pasting as this will empty the buffer.

7. List out the different attributes of a file.Ans.:- Listing File Attribute:-

-rw-r----- 1 sibnas sibgrp 4562 sep 22 10:30-rw-r----- 1 sibnas sibgrp 8976 sep 22 10:30-rw-r----- 1 sibnas sibgrp 10234 sep 22 10:30-rw-r----- 1 sibnas sibgrp 4352 sep 22 9:30-rw-r--r--r- 1 sibnas sibgrp 87632 aug 2 11:30-rw-r--r--r- 1 sibnas sibgrp 6528 june 20 10:30-rw-r--r--r- 1 sibnas sibgrp 9234 may 22 10:00

File type link User id group id file size date &

Count in bytes of modi.

8. What are the different ways of coming out of vi after saving the file?

Ans.:- There are three different ways to quit vi after saving the file:

a. :wq

b. :x

c. ZZ

Page 32: Java Programming for Bsc It 4th Sem kuvempu university

5/13/2018 Java Programming for Bsc It 4th Sem kuvempu university - slidepdf.com

http://slidepdf.com/reader/full/java-programming-for-bsc-it-4th-sem-kuvempu-university 32/52

 

9. Write general syntax of CASE statements.

Ans. :- The case statement compares word with pattern; if they match ,the shell runs thecommand on the first line. Otherwise the shell checks the remaining patterns ,one by one,until it finds one that matches the word; it then runs the command on that online.

Syntax for case statement:-#!/bin/shSet „date‟ Case $1 inFri) echo “thank goodness it‟s Friday!”;; Sat | Sun) echo “you should not work on week -ends”; 

Echo “log off and go home!”;; *) echo “it is not yet the weekend.”; 

Echo “get to work! “;; esac

10. What is a process ? Name two important attributes of a process.Ans :- Process is born when a program starts execution and exists as long asthe program is running. After execution the process is usually the name of theprogram being executed.The two important attribute of a process are:-1) The process-id(PID).Each process is identified by a unique number calledthe process-id which is allotted by the kernel when the process is born.2) The parent PID(PPID) the PID of the parent is also a process attribute.When many processes have the same PPID it is easier to kill the parentprocess rather than the children separately.PART - B1. a) Explain layered architecture of unix operating system. With a suitable

command explain the interaction between Shell and Kernel.Ans.:-Unix, like other operating systems, is a layer between the hardware and theapplications that run on the computer. it has functions that manage the hardwarefunctions that manage executing applications. So what‟s h difference between UNIX andany other operating system? Basically two things: internal implementation and theinterface that is seen and used by users.The part of UNIX that manages the hardware and the executing processes is called thekernel. The kernel is collection of programs written in c which directly communicate withthe hardware . Application programs communicate with the hardware by using theservices of Kernel. Along with the memory management, the kernel also schedulesprocesses and decides their priorities.In the Unix system , each hardware device is viewed as a file and is called a device file.this allows the same simple method of reading and writing files to be used to access each

hardware device.The user commands are translated in to action by the shell which acts as interpreter. Theshell forms the outer part of the operating systems and forms the interface between theuser and kernel. for each user logged in, there is shell in action. When a command is

Page 33: Java Programming for Bsc It 4th Sem kuvempu university

5/13/2018 Java Programming for Bsc It 4th Sem kuvempu university - slidepdf.com

http://slidepdf.com/reader/full/java-programming-for-bsc-it-4th-sem-kuvempu-university 33/52

 

given by the user, it is examined by the shell and communicated to the kernel for

execution.Application portability is the ability of a single application to be executed on varioustypes of computer hardware without being modified. This can be achieved if theapplication uses the UNIX interface to manage its hardware needs.

b) Explain uname command with different options.Ans.:- uname – displays the name of the operating systemSyntax

uname [options]Examples:Displays all the information$uname – aSCO_SV sco5 3.2 5.0.5 i386Displays the machine‟s node name in the communication network. 

$uname-nSco-5Displays the operating system release.

$uname-r3.2Displays the name of the operating system

$uname – s

SCO_SVDisplays the operating system version

$uname – v5.0.5Displays the information about system name, node name, operating system

release number, kernel ID, processor type, serial number, number of userslicense, OEM number, origin number and number of CPUs.2. a) Explain the advantages of ispell, list out the basic commands used in ispell.Ans.:-b) Explain unix file system and give the difference between relative and absolutepathname.

Ans.:-Unix file system can be defined as belonging to one of four possible types:-Ordinary files: ordinary files can contain text, data, or program information. An ordinaryfile cannot contain another file, or directory. An ordinary file can be a text file or binaryfile. Most of the UNIX command are binary files.

Page 34: Java Programming for Bsc It 4th Sem kuvempu university

5/13/2018 Java Programming for Bsc It 4th Sem kuvempu university - slidepdf.com

http://slidepdf.com/reader/full/java-programming-for-bsc-it-4th-sem-kuvempu-university 34/52

 

Directory files :- Directories are containers that can hold files, and other directories. A

directory is actually implemented as a file that has one line for each item containedwithin the directory. Each line in a directory file contains only the name of the item, anda numerical reference to the location of the item.Special files :- Special files represent i/o devices like, a tty, a disk drive, or a printer.Because UNIX treats such devices as files. Some of the commands used to accessordinary files will also work with devices files. This allows more efficient use of software.Links:- A link is a pointer to another file. Since a directory is alist of the names and i-numbers of files, directory entry can be a hard link. In which the i-number points directlyto another file. A hard link to a file cannot be distinguished from the file itself.

Difference between ABSOULATE AND RELATIVE PATHNAMES

ABSOULATE PATHNAMES RELATIVE PATHNAMESAn Absoulate pathname specifies thelocation of a file .

Relative pathname specifies a file inrelation to the current directory.

An Absoulate pathname starts at the / root directory.

A Relative pathname starts from thecurrent directory.

An Absoulate pathname uses a slash (/)between each directory name in thepath to indicate different directories.

In a Relative pathname, a single dot (.)represents the current working directoryand two dots (..) represent the parent of the current working directory.

3. a) Explain how to split file into multiple files. Give suitable example.Ans. :- we used “split” command to split file into multiple files. 

split –  split large files into “smaller files” syntax –  

split[options] filename prefixwhere file name is the name of the large file to be split ,prefix is the name to be

given the small output files and options can either be excluded or can be one of the or canbe one of the following:-

-l = linenumber-b = bytes

If  – l option is used, linenumber will be the number of the lines to be put in each of thesmaller files (the default is 1000). If the – b option is used ,bytes will be the number of bytes to be put in each of the smaller files.The split command will give each output file created the name prefix with an extensionattached to the end to indicate its orderEXAMPLE :

Assuming that file.txt is 3000 lines long , it will output three files, xaa, xab,and xac, and each one will be 1000 lines long.

$ splitfile.txt

Page 35: Java Programming for Bsc It 4th Sem kuvempu university

5/13/2018 Java Programming for Bsc It 4th Sem kuvempu university - slidepdf.com

http://slidepdf.com/reader/full/java-programming-for-bsc-it-4th-sem-kuvempu-university 35/52

 

This will output six soo-line files: fileaa, fileab, fileac,filead, fileae, and fileaf.

$split-1500 file.txt fileAssuming that file.txt has 200 kb ,this will output five 40 kb files: fileaa, fileab, fileac,filead, fileae, and fileaf.

$ split – b 40k .txt fileb) Give the difference between Hard Link and Symbolic Link.Ans: - Soft Link:-------------- Soft links are links to a file but not the inode.- Created usingln -s file1 file2

=> ls -il

131135 lrwxrwxrwx 1 user user 5 Jul 10 09:04 file2 -> file1131137 -rw-r--r-- 1 user user 35 Jul 10 09:03 file1

- The inode for file1 is 131137 and inode for file2 is 131135.- If you see the permission bits, there is 'l' in the front for a soft link.- If file1 is deleted, the link still exists. But if you try to view file2, its empty. This meansthat once the main file is deleted the data is gone.

Hard Link:--------------- Hard links are links to inode

- Created using

ln file1 file2

=> ls -il

131136 -rw-r--r-- 2 user, user 48 Jul 10 09:27 file1131136 -rw-r--r-- 2 user, user 48 Jul 10 09:27 file2

- The inode for file1 and file2 is the same (131136).- If you see the output above for "ls -i", file2 does not show that it is linked to file1. Inreality it is not linked to file1 but it is linked to the inode.- If you see that there is number '2' before the username 'user'. This shows the number of 

hard links to the inode.- If file1 is deleted, the data is not deleted. If you view file2 the data is still there.Deleting file1 only deletes a link. The data is gone once the last hard link is deleted.

Page 36: Java Programming for Bsc It 4th Sem kuvempu university

5/13/2018 Java Programming for Bsc It 4th Sem kuvempu university - slidepdf.com

http://slidepdf.com/reader/full/java-programming-for-bsc-it-4th-sem-kuvempu-university 36/52

 

4. a) What is a process? Explain the mechanism of creation in unix.

Ans :-A process is a collection of interrelated work tasks initiated in response to an event thatachieves a specific result for the customer of the process.

Adding more specific detail to that general definition:

  that achieves a specific result: 

must deliver a specific resultthis result must be individually identifiable and countablea good process name clearly indicates the result or end state of the process

  for the customer of the process: 

a customer receives the result or is the beneficiary of itthe customer can be a person or an organizationcustomer can be identified and can pass judgment on the result and processcustomer point of view helps identify and name the process accurately

  initiated in response to a specific event: 

the process must be initiated in response to a specific eventmultiple events can initiate a processhaving an event AND a result allows the tracing of the sequence of tasksthat turns the event into the result

  work tasks: 

a collection of actions, activities, steps or tasks make up a business processa step in the initial workflow will probably be divided into more detailedsteps later

  a collection of interrelated: 

the process steps must relate to each otherinterrelationship is through sequence and flow...the completion of one stepleads to (flows into) the initiation of the next stepalso interrelated by dealing with the same work itemsteps related by being traceable back to the same initiation event

b) List out the navigation keys for the cursor movement.Ans. :- in the command mode ,navigation keys for the movement of the cursor by

characters, words and lines are as follows:

Keys Movement of cursor

H Cursor moves left

Page 37: Java Programming for Bsc It 4th Sem kuvempu university

5/13/2018 Java Programming for Bsc It 4th Sem kuvempu university - slidepdf.com

http://slidepdf.com/reader/full/java-programming-for-bsc-it-4th-sem-kuvempu-university 37/52

 

J Cursor moves down

K Cursor moves upL Cursor moves rightW Word forwardB Word backward

E End of word^ First character$ End of line0 Beginning of line

The screen display can be controlled by scrolling the display forward and backwardusing the following keys:-

Keys Screen display

[ctrl-f] Scroll display forward[ctrl-h] scroll display backward[ctrl-d] Scroll half-screen forward

[ctrl-u] Scroll half-screen backward

5. a) Explain grep command with at least 5 examples with different options.

Ans.- 1) A simple Linux grep example - searching for a text string in one file

This first grep command example searches for all occurrences of the text string 'fred'within the "/etc/passwd" file. It will find and print (on the screen) all of the lines in thisfile that contain the text string fred, including lines that contain usernames like "fred" -and also "alfred".

grep 'fred' /etc/passwd

In a simple grep example like this, the quotes around the string fred aren't necessary, butthey are needed if you're searching for a string that contains spaces, and may be neededwhen you get into using regular expressions (search patterns).

2) Linux grep command - searching for a string in multiple files

Our next grep command example searches for all occurrences of the text string joe withinall files of the current directory:

grep 'joe' *

The '*' wildcard matches all files in the current directory, and the grep output from thiscommand will show both (a) the matching filename and (b) all lines in all files thatcontain the string 'joe'.

Page 38: Java Programming for Bsc It 4th Sem kuvempu university

5/13/2018 Java Programming for Bsc It 4th Sem kuvempu university - slidepdf.com

http://slidepdf.com/reader/full/java-programming-for-bsc-it-4th-sem-kuvempu-university 38/52

 

As another example, you can also use grep to search all files in the current directory that

end in the file extension ".txt", as shown here:

grep 'joe' *.txt

3) Case-insensitive file searching with the Unix grep command

To perform a case-insensitive search with the grep command, just add the -i option, likethis:

grep -i score gettysburg-address.txt

This grep search example matches the string "score", whether it is uppercase, lowercase,or any mix of the two.

4) Reversing the meaning of a grep search

You can reverse the meaning of a Linux grep search with the -v option. For instance, toshow all the lines of my /etc/passwd file that don't contain the string fred, I'd issue thisgrep command:

grep -v fred /etc/passwd

5) Using grep in a Unix/Linux command pipeline

The grep command is often used in a Unix/Linux pipeline. For instance, to show all theApache httpd processes running on my Linux system, I can use the grep command in a

pipeline with the 'ps' command:

ps auxwww | grep httpd

b) Explain Uniq command.

Ans.- The default output is to display lines that only appear once and one copy of linesthat appear more than once. It is also useful to filter out multiple blank lines fromunsorted output of other commands. For example, the dircmp command displays itsoutput using pr; thus the output usually scrolls off your screen before you can read it. Butif you pipe the output of the dircmp command through the uniq command, the blank lines are reduced and the output is more compact.

  -u Print only lines which are not repeated (unique) in the original file  -d Don't output lines that are not repeated in the input.

Page 39: Java Programming for Bsc It 4th Sem kuvempu university

5/13/2018 Java Programming for Bsc It 4th Sem kuvempu university - slidepdf.com

http://slidepdf.com/reader/full/java-programming-for-bsc-it-4th-sem-kuvempu-university 39/52

 

  -c Generate an output report in default style except that each line is preceded by a

count of the number of times it occurred. If this option is specified, the -u and -doptions are ignored if either or both are also present.

  -i Ignore case differences when comparing lines  -f Ignore a number of fields in a line  -s Skips a number of characters in a line  -w Specifies the number of characters to compare in lines, after any characters and

fields have been skipped  --help Displays a help message  --version Displays version number on stdout and exits.

6. a) Explain the mechanism of executing job periodically using cron.Ans. A task can be automatically run in the background at regular intervals by a Unixutility called cron.The cron daemon takes care of running these background jobs, which are called cron

 jobs.crontab or the crontable is a file which contains the schedule of cron entries to be run andat specified times. cron checks the crontable at regular tables to see if there are any jobsscheduled. A user can execute crontab if the user‟s name appears in the file

 /usr/lib/cron/cron.allow. If the cron.allow does not exist, the cron.deny file in /usr/lib/cronis checked. If the user‟s name is not in this file the user is allowed to use crontab. If onlycron.deny exists and is empty, all users can use crontab. If neither file exists, only theroot user can use crontab. The allow and deny files contain one user name per line.

b) Write a shell script to add two numbers by using Expr utility.

Ans.:- To use it in a shell script, you simply surround the expression with backquotes. Forexample, let‟s write a simple script called add that adds two numbers typed as arguments:# /bin/sh# Shell Script to Add two numberssum=„expr $1 + $2„ echo $sumHere we defined a variable sum to hold the result of the operation. (Note the spacesaround the plussign, but not around the equals sign). To run this script, we might type the following line:(assume the scriptadd is executable)$ add 4 3The first argument (4) is stored in $1, and the second (3) is stored in $2. The expr utility

then addsthese quantities and stores the result in sum. Finally, the contents of sum are echoed onthe screen:7

Page 40: Java Programming for Bsc It 4th Sem kuvempu university

5/13/2018 Java Programming for Bsc It 4th Sem kuvempu university - slidepdf.com

http://slidepdf.com/reader/full/java-programming-for-bsc-it-4th-sem-kuvempu-university 40/52

 

$

The expr command only works on integers (i.e., whole numbers). It can perform addition(+), subtraction(-), multiplication (*), integer division (/), and integer remainder (%).

7. a) What are positional parameters? Explain the command used to set thepositional parameters.Ans. – These are used by the shell to store the values of command-linearguments.The command which used to set the positional parameter#!/bin/sh

# Demonstrate the set commandset „date„ echo “Time: $4 $5” echo “Day: $1” echo “Date: $3 $2 $6” Assuming that setdate has been made executable with the chmod command, we can runthe script bytyping the command$ setdateThe output will look something like this:Time:10:56:08 ESTDay: FriDate: 20 Aug 2004What happened? Consider the command lineset „date„ 

The backquotes run the date command, which produces output something like this:Fri Aug 20 10:56:08 EST 2004This does not appear on the screen. Instead, the set command catches the output andstores it in thepositional parameters $1 through $6:$1 contains Fri$2 Contains Aug$3 contains 20$4 contains 10:56:08$5 contains EST$6 contains 2004

b) Explain Head Command with example.

Ans :- The head command, as the name implies, displays the top of the file. When usedwithout an option, itdisplays the first ten lines of the file.You can use the –n option to display the first „n‟ number of lines. 

Page 41: Java Programming for Bsc It 4th Sem kuvempu university

5/13/2018 Java Programming for Bsc It 4th Sem kuvempu university - slidepdf.com

http://slidepdf.com/reader/full/java-programming-for-bsc-it-4th-sem-kuvempu-university 41/52

 

$ head emp.lst Shows first ten lines of the emp.lst file

The head command, as the name implies, displays the top of the file. When used withoutan option, itdisplays the first ten lines of the file.You can use the –n option to display the first „n‟ number of lines. $ head emp.lst Shows first ten lines of the emp.lst file

1001|T.N.Raju |Professor |Information Science|14/06/61|300001004|D.S.Raghu |Lecturer |Information Science|05/12/75|170001005|S.K.Anantha |Asst.Prof. |Information Science|20/07/63|240001009|M.P.Rajendra |Sr.Lecturer |Computer Science |13/03/66|200001002|Mallu |Lecturer |Information Science|20/07/74|15000

7. a) What are positional parameters? Explain the command used to set the

positional parameters.

Positional paremeters:-These are used by the shell to store the values of command-line

arguments.

The command which are used to set the positional parameter

#!/bin/sh

# Demonstrate the set command

set „date„ 

echo “Time: $4 $5” 

echo “Day: $1” 

echo “Date: $3 $2 $6” 

Assuming that setdate has been made executable with the chmod command, we can runthe script by

typing the command

$ setdate

The output will look something like this:

Time:10:56:08 EST

Day: Fri

Date: 20 Aug 2004

What happened? Consider the command line

Page 42: Java Programming for Bsc It 4th Sem kuvempu university

5/13/2018 Java Programming for Bsc It 4th Sem kuvempu university - slidepdf.com

http://slidepdf.com/reader/full/java-programming-for-bsc-it-4th-sem-kuvempu-university 42/52

 

set „date„ 

The backquotes run the date command, which produces output something like this:

Fri Aug 20 10:56:08 EST 2004

This does not appear on the screen. Instead, the set command catches the output andstores it in the

positional parameters $1 through $6:

$1 contains Fri

$2 Contains Aug

$3 contains 20

$4 contains 10:56:08

$5 contains EST

b) Explain Head Command with example.

“head command ” displays the top of the file.

Example:-

$ head emp.1st

It displays the first ten lines of the file.

We can use –n option with the head command to display the first „n‟ number of lines. 

$ head – n 3 emp.1st

This displays the first 3 lines of the file.

8. Explain the options and associated actions for ls command.Ans :- The Is command shows the contents of a directory , and a view of basicinformation (like size ,ownership, and access permission) about files and directories.

The options and associated actions for Is command are:

OPTION ACTION-1 One file name in each line

-a All files including those beginning with a dot(.), current

directory (.) and directory above (..)-A All files including those beginning with a dot(.).does not list

current directory(.) and directory above.-d If an argument is a directory ,lists only its name (not its contents)

Page 43: Java Programming for Bsc It 4th Sem kuvempu university

5/13/2018 Java Programming for Bsc It 4th Sem kuvempu university - slidepdf.com

http://slidepdf.com/reader/full/java-programming-for-bsc-it-4th-sem-kuvempu-university 43/52

 

-F Marks directories with a /,executables with a * and symbolic

links with a @-I Shows the inode number-l Lists in long format , giving mode, number of links, owner,

group, size in bytes, the time that each file was last modified.-p Puts a slash (/) after each directory.-r Sorts the filenames in the reverse order-R Recursive list

-t Sorts by time modified (latest first)-u Sorts by last access time

Assignment: TB (Compulsory) 44

PART – A

I. Fill up the blanks using suitable word or phrase in the following sentences:

1) Software is a set of _____________that when executed provide desired functionand performance.Ans. INSTRUCTIONS OR COMPUTER PROGRAMS

2) Software is a process and _____________.Ans.:- PRODUCT

3) The_____________method is also known as the iterative enhancement model.Ans. INCREMENTAL MODEL

4) An external entity is represented using _____________ in a DFD.Ans. EXTERNAL DESIGN INTERFACE

5) The software requirements deal with the_____________of the proposed system.Ans.- REQUIREMENTS

6) The weakest coupling that is most desirable is _____________.Ans.- DATA COUPLING

7) The three important levels of abstraction are _____________,_____________,and_____________.

Ans. PHYSICAL LEVEL, LOGICAL LEVEL ,VIEW LEVEL

8) P.D.L. stands for_____________.Ans. PROGRAM DESIGN LANGUAGE

Page 44: Java Programming for Bsc It 4th Sem kuvempu university

5/13/2018 Java Programming for Bsc It 4th Sem kuvempu university - slidepdf.com

http://slidepdf.com/reader/full/java-programming-for-bsc-it-4th-sem-kuvempu-university 44/52

 

9) _____________helps to view the source code.

Ans. BROWSING TOOLS

10) _____________tools help in code creation, debugging and testing.Ans.- EXECUTABLE CODE

11) The two kinds of program documentation are _____________and_____________Ans. – INTERNAL AND EXTERNAL

12) Estimation makes use of an important approach_____________.Ans.- DECOMPOSITION

13) PERT stands for_____________.Ans. :- PROGRAM EVALUATION AND REVIEW TECHNIQUE

II. Write brief answers to the following questions:1) Define the terms risk mitigation, risk monitoring.

Ans.:- Risk mitigation refers to avoiding risks by developing a strategy for reducing theturn over thereby adopting a proactive approach to risks. Risk monitoring refers tomonitoring the facts that may provide an indication of whether the risk is becoming moreor less likely.

2) Name the important approaches used in program debugging.Ans.:- There are three debugging approaches commonly used

- It occurs as a consequence of successful testing.-

When a test can uncovers an error, then debugging, a process thatresults in the removal of errors occur.- Debugging process begins with the execution of test cases.-

3) What are specification languages? Give an example.Ans.:- specification languages posses many desired qualities of an SRS. Unlike formallanguages of SRS must be exact, without ambiguity, and precise because the designspecification, statement of work, and other project documents are what drive thedevelopment of the final product. Example :-Structured English, Regular Expression.PART - B

1. a) What is software? List out the important characteristics of software.Ans.:- Software is a set of instructions of computer programs that when executed providedesired function and performance. It is both a process and a product. To gain an

understanding of software, it is important to examine the characteristics of software,which differ considerably from those of hardware.Software Characteristic

1). Software is developed or engineered, it is not manufactured.

Page 45: Java Programming for Bsc It 4th Sem kuvempu university

5/13/2018 Java Programming for Bsc It 4th Sem kuvempu university - slidepdf.com

http://slidepdf.com/reader/full/java-programming-for-bsc-it-4th-sem-kuvempu-university 45/52

 

Unlike hardware, software is logical rather than physical. It has to be designed

well before producing it. In spite of availability of many automated softwaredevelopment tools, it is the skill of the individual, creativity of the developers and propermanagement by the project manager that counts for a good software product.

2). Software does not “wear out”. The hardware components start deteriorating – they are subjected to

environmental maladies such as dust, vibration, temperature etc. and at some point of time they tend to breakdown. The defected components can then be traced and replaced.

3) Most software is custom-built, rather than being assembled from existingcomponents

Most of the engineered products are first designed before they aremanufactured. Designing includes identifying various components for the product beforethey are actually assembled. Here several people can work independently on thesecomponents thus making the manufacturing system highly flexible. in software , breakinga program into modules is a difficult task, since each module is highly interlinked withother modules.

b) Explain the waterfall model of software process. What are its limitations?Ans.:-It is the simplest and the widely used process model for software development.Here the phases involved in the software development are organized in a linear order.In a typical waterfall model, a project begins with the feasibility analysis. on successfullydemonstrating the feasibility of a project, the requirements analysis and project planningbegins. The design starts after completing the requirements analysis and coding startsafter completing the design phase.The limitations of waterfall model are:

nThe model states that the entire set of requirements should be frozen

before development begins. This is possible for small projects, but isdifficult for large projects where the exact requirements may not beknown in advance.

nThe waterfall model requires formal documents after each phase. Thisis not possible in GUI-based applications where the documentationwill be very extensive.

nThe customer sees the software only at the end of the developmentphase. As a result, the customer cannot suggest any changes until theproduct is delivered.

2. a) Describe the three generic views of software engineering.Ans.:- The software engineering as such can be categorized in to three generic phases,

regardless of application area, project size or complexity.The three generic phases of software engineering are :-

  The definition phase

  The development phase

 

Formatted: Bullets and Numbe

Page 46: Java Programming for Bsc It 4th Sem kuvempu university

5/13/2018 Java Programming for Bsc It 4th Sem kuvempu university - slidepdf.com

http://slidepdf.com/reader/full/java-programming-for-bsc-it-4th-sem-kuvempu-university 46/52

 

  The maintenance phase

The definition phase developer attempts toidentify what information is to be processed, what function and performance are desired,what system behavior can be expected, what interfaces are to be established, what designconstraints exists, and what validation criteria are required to define a successful system.

The development phase attempts to definehow data are to be structured, how function is to be implemented as a softwarearchitecture, how produces are to be implemented, how design will be translated, into aprogramming language, how testing will be performed.

The maintenance phase focus on changethat is associated with the software.Correction:- it is likely that are customers will find errors or defects in the software inspite of quality assurance activities.Adaptations – As time progress, it is likely that the original environment for which thesoftware was developed is likely to change.Enhancement – as software is used, the customer will recognize the need for additionalfunctional requirements that will benefit him.Prevention – computer software deteriorates due to change. so, preventive maintenance,often called software reengineering must be conducted in order to make changes to thecomputer software more easily.

b) List out the important characteristics of good SRS.

Ans.:- A good SRS should be:

n

 

Completen

 

Consistent

nAccuratenModifiablenRankednTestablenTraceablenUnambiguousnValid

3. a) Give the outline structure of SRS.

Ans.:- The outline of SRS structure is:

Introduction

1.1 Purpose

1.2 Document conventions

1.3 Intended audience

1.4 Additional information

 

Formatted: Bullets and Numbe

Page 47: Java Programming for Bsc It 4th Sem kuvempu university

5/13/2018 Java Programming for Bsc It 4th Sem kuvempu university - slidepdf.com

http://slidepdf.com/reader/full/java-programming-for-bsc-it-4th-sem-kuvempu-university 47/52

 

1.5 Contact information/SRS team members

1.6 References

Overall Description

2.1 Product perspective

2.2 Product functions

2.3 User classes and characteristics

2.4 Operating environment

2.5 User environment

2.6 Design/implementation constraints

2.7 Assumptions and dependencies

External Interface Requirements

3.1 User interfaces

3.2 Hardware interfaces

3.3 Software interfaces

3.4 Communication protocols and interfaces

System Features

4.1 System feature A

4.1.1 Description and priority4.1.2 Action/result4.1.3 Functional requirements

4.2 System feature B

Other Nonfunctional Requirements

5.1 Performance requirements

5.2 Safety requirements

5.3 Security requirements5.4 Software quality attributes

5.5 Project documentation

Page 48: Java Programming for Bsc It 4th Sem kuvempu university

5/13/2018 Java Programming for Bsc It 4th Sem kuvempu university - slidepdf.com

http://slidepdf.com/reader/full/java-programming-for-bsc-it-4th-sem-kuvempu-university 48/52

 

5.6 User documentation

b) Why is design an important phase in software development life cycle? Describedesign process.

Ans.:- Design is an important phase in the software development life cycle because itbridges the requirements specification and the final solution for satisfying therequirements.

The software design is an activity which is after the requirements analysis activity. Thisphase begins when the requirements document for the system to developed is available.Design is an important phase in the software development life cycle, it bridges therequirements specification and the final solution for satisfying the requirements.

The design process for the software has two levels:-

1. System design or top-level design

2. Detailed design or logic design

System design

Using this, the modules that are needed for the system are decided, thespecifications of these modules and how these modules need to be connected are alsodecided.

Detailed design

Using this, the internal design of the modules are decided or how thespecifications of the modules can be satisfied are decided. This type of design essentiallyexpands the system design to contain more detailed description of the processing logic

and data structures so that the designs is sufficiently complete for coding.4. Outline programming guidelines with regard to;i) Control structures ii) Algorithmsiii) Data structures and iv) General guidelinesi) Control Structures :- Many of the control structures for a program component are givenby the architecture and design of a system. And the given design is translated in to code.In case of some architecture, such as implicit invocation and object-oriented design,control is based on the system states and changes in variables.ii) Algorithms:- The program design often specifies a class of algorithms to be used incoding. For example, the design may tell the programmer to use binary search technique.Even though, a programmer has lot of flexibility in converting the algorithm to code, itdepends on the constraints of the implementation language and hardware.

iii) Data Structures :- Data structures can influence the organization and flow of aprogram. In some cases , it can even influence the choice of programming language. Forexample, LISP is a language for list processing. It is so designed that it containsstructures that make it much easier for handling lists than other languages.

Page 49: Java Programming for Bsc It 4th Sem kuvempu university

5/13/2018 Java Programming for Bsc It 4th Sem kuvempu university - slidepdf.com

http://slidepdf.com/reader/full/java-programming-for-bsc-it-4th-sem-kuvempu-university 49/52

 

iv) General Guidelines :- there are several strategies that are useful in preserving the

design quality of a program:-  Localization input and output :- those parts of a program that

read input or generate output are highly specialized and mustreflect characteristics of the underlying hardware and software .

  Pseudo-code can be used for transforming the design to codethrough a chosen programming language.

  Revise the design and rewrite the code until one is completelysatisfied with the result.

  Reuse code components if possible.5. a) What is software testing ? Describe the two ways of testing any engineeredsoftware product.Ans.:- Software testing is the process of testing the functionality and correctness of 

software by running it.The two ways of testing any engineered software product :-1) White-Box Testing2) Black-Box testing

Black-box testingIt is also known as functional testing. Knowing the specified function that

the product has been designed to perform, tests can be conducted to demonstrate thateach function is fully operationalExample :- Boundary value analysis.White Box Testing

It is also known as structural testing. Knowing the internal working of product, test can be conducted to ensure that all internal operations perform according tospecification that all internal components have been adequately.

EXAMPLE :- basic path testing.b) What is the difference between verification and validation ?

Ans.:- Verification is a set of activities that ensures that the software correctlyimplements a specified function while Validation is a set of activities that ensures that thesoftware that has been built, is traceable to the customer requirements.

6. a) Describe the different kinds of software development team structure.

Ans.:- The different kinds of software development team structure are:

nDemocratic decentralized teamn

 

Controlled centralized teamControlled decentralized team

Democratic decentralized team

  It consists of ten or few number of programmers.

  The goals of the group are set by consensus

Formatted: Bullets and Numbe

Page 50: Java Programming for Bsc It 4th Sem kuvempu university

5/13/2018 Java Programming for Bsc It 4th Sem kuvempu university - slidepdf.com

http://slidepdf.com/reader/full/java-programming-for-bsc-it-4th-sem-kuvempu-university 50/52

 

  Every member is considered for taking major decision

  Group leadership rotates among group member

Controlled centralized team

  It consists of a chief programmer, who is responsible for all themajor technical decisions of the project. He also does most of the design activities and allocates coding part to each and everymember of the team.

  Under him, he has a backup programmer, program librarian,and programmers

  The backup programmer helps the chief in making decisions andtakes over the role of chief in absence of the chief programmer.

 

The program librarian is responsible for maintaining thedocuments and other communication related work.

Controlled decentralized team

  It combines the strength of the democratic and chief programmer teams

  It consists of a project leader who has a group of seniorprogrammers under him and a group of junior programmersunder a senior programmer.

  The communication between the senior and juniorprogrammers are like ego-less team,

  This structure is best suited for every simple projects orresearch-type works.

b) What is COCOMO model? Explain the basic COCOMO model.Ans.:-The COCOMO model predicts the effort and duration of a project based on inputsrelating to the size of the resulting system and a number of  “cost drivers” that affectproductivity.THE BASIC COCOMO MODEL

Basic COCOMO model estimates the software development effort using only asingle predictor variable and three software development modes. Basic COCOMO isgood for quick, early, rough, order of magnitude estimates of software costs, but itsaccuracy is necessarily limited because of its lack of factors which have a significantinfluence on software costs. The basic equation for the COCOMO model is about theeffort estimate in persons – month required develop a project and the KLOC, the number

of delivered lines of code for the project.7. a) Define the terms: quality, quality assurance and quality control.

Page 51: Java Programming for Bsc It 4th Sem kuvempu university

5/13/2018 Java Programming for Bsc It 4th Sem kuvempu university - slidepdf.com

http://slidepdf.com/reader/full/java-programming-for-bsc-it-4th-sem-kuvempu-university 51/52

 

Ans.:- QUALITY:- Software quality is conformance to the explicitly stated functional

and performance requirements, explicitly documented development standards, andimplicit characteristics that are expected of all professionally developed software.

QUALITY ASSURANCE :- Quality assurance is an auditing and reporting function of management.

QUALITY CONTROL :- Quality control consists of a series of activities likeinspections, reviews, and tests, which are carried out during the entire life cycle of software, so that each work product meets the requirements, placed upon it.

b) Mention the objectives of formal technical review.Ans.:- This is a software quality assurance activity that is performed by software

engineers.OBJECTIVES

  To detect the errors in functions, logic or implementation found insoftware.

  To verify that the software under review meets its requirements.

  To ensure that the software has been represented according topredefined standards

  To achieve software with consistent quality and on time

  To make projects more manageable.

  It acts as a training ground for junior engineers to observe differentapproaches to software analysis, design, implementation

  FTR includes walkthroughs, inspections, round-robin reviews.

8. Write short notes on:a) Software engineeringAns.:-Software engineering is a discipline. It uses the existing tools and methods of software development and systematizes the entire process of software development.There are a number of formal definitions for software engineering, given by experts inthe field. However for the purpose of understanding , we shall see some of them.

“The application of a systematic, disciplined, quantifiable approachto the development, operation, and maintenance of software, that is , the application of engineering to software “. b) The spiral model of software processAns.:-The activities in this model can be organized like a spiral, that has many cycles.Typically the inner cycles represent the early phase of requirement analysis along withthe prototyping and the outer spirals represent the classic software lifecycle.

This model has been divided into four quadrants, each quadrant representing amajor activity like planning, risk analysis engineering and customer evaluation. Thesoftware process cycle begins with the planning activity represented by the first quadrant

Page 52: Java Programming for Bsc It 4th Sem kuvempu university

5/13/2018 Java Programming for Bsc It 4th Sem kuvempu university - slidepdf.com

http://slidepdf.com/reader/full/java-programming-for-bsc-it-4th-sem-kuvempu-university 52/52

 

of this model. Each cycle here begins with the identification of objectives for that cycle,

the alternatives and constraints associated with that objective.

c) Programming tools.Ans.:-programming tools is used to reduce time spent on the development of programs.

The tools which used in programming tools1) source-code tools

- editing tools, these relate to the editing of source code- browsing tools, helps to view the source code

The source-code beautifiers and templates not only makes a program look consistent but also standardize indentation styles, align variable declarations and formatcomments.

2) Executable code toolsTools that are required for working with executable codes. it helps in code creation,

debugging and testing3) code creation has four major tools which help the developer in converting the

source code into executable code :4) Debugging tools help in debugging the code.5) testing tools help in tracing the code errors.