Subscribe

RSS Feed (xml)

Powered By

Skin Design:
Free Blogger Skins

Powered by Blogger

Search Your Question

Thursday, October 2, 2008

Cobol Interview Questions Part-11

151. What are the few advantages of VS COBOL II over OS/VS COBOL?

Ans: The working storage and linkage section limit has been increased. They are 128 megabytes as supposed to 1 megabytes in OS/VS COBOL.

Introduction of ADDRESS special register.

31-bit addressing. In using COBOL on PC we have only flat files and the programs can access only limited storage, whereas in VS COBOL II on M/F the programs can access up to 16MB or 2GB depending on the addressing and can use VSAM files to make I/O operations faster

152. What are the steps you go through while creating a COBOL program executable?

Ans: DB2 pre-compiler (if embedded SQL is used), CICS translator (if CICS program), Cobol compiler, Link editor. If DB2 program, create plan by binding the DBRMs.

153. Name the divisions in a COBOL Program

Ans: Identification / Environment/ Data/ Procedure Divisions

154. What are the different data types available in COBOL?

Ans: Alpha-numeric (X) , Alphabetic (A) and numeric (9).

155. What does the INITIALIZE verb do?

Ans: Alphabetic, Alphanumeric fields & alphanumeric edited items are set to SPACES. Numeric, Numeric edited items set to ZERO. FILLER , OCCURS DEPENDING ON items left untouched

156. What is the difference between a 01 level and 77 levels?

Ans: 01 level can have sublevels from 02 to 49. 77 cannot have sublevel.

157. What are 77 levels used for?

Ans: Elementary level item. Cannot be subdivisions of other items (cannot be qualified), nor can they be subdivided themselves.

158. What is 88 level used for?

Ans: For condition names.

159. What is level 66 used for?

Ans: For RENAMES clause.

160. What does the IS NUMERIC clause establish?

Ans: IS NUMERIC can be used on alphanumeric items, signed numeric & packed decimal items and unsigned numeric & packed decimal items. IS NUMERIC returns TRUE if the item only consists of 0-9. However, if the item being tested is a signed item, then it may contain 0-9, + and - .

161. Is compute w=u a valid statement?

Ans: Yes, it is. It is equivalent to move u to w.

162. In the above example, when will you prefer compute statement over the move statement?

Ans: When significant left-order digits would be lost in execution, the COMPUTE statement can detect the condition and allow you to handle it. The MOVE statement carries out the assignment with destructive truncation. Therefore, if the size error is needs to be detected, COMPUTE will be preferred over MOVE. The ON SIZE ERROR phrase of COMPUTE statement, compiler generates code to detect size-overflow.

163. What happens when the ON SIZE ERROR phrase is specified on a COMPUTE statement?

Ans: If the condition occurs, the code in the ON SIZE ERROR phrase is performed, and the content of the destination field remains unchanged. If the ON SIZE ERROR phrase is not specified, the assignment is carried out with truncation. There is no ON SIZE ERROR support for the MOVE statement.

164. How will you associate your files with external data sets where they physically reside?

Ans: Using SELECT clause, the files can be associated with external data sets. The SELECT clause is defined in the FILE-CONTROL paragraph of Input-Output Section that is coded Environment Division. The File structure is defined by FD entry under File-Section of Data Division for the OS.

165. How will you define your file to the operating system?

Ans: Associate the file with the external data set using SELECT clause of INPUT-OUTPUT SECTION. INPUT-OUTPUT SECTION appears inside the ENVIRONMENT DIVISION.

166. Explain the use of Declaratives in COBOL?

Ans: Declaratives provide special section that are executed when an exceptional condition occurs. They must be grouped together and coded at the beginning of procedure division and the entire procedure division must be divided into sections. The Declaratives start with a USE statement. The entire group of declaratives is preceded by DECLARIVES and followed by END DECLARITIVES in area A. The three types of declaratives are Exception (when error occurs during file handling), Debugging (to debug lines with 'D' coded in w-s section) and Label (for EOF or beginning...) declaratives.

167. How do you define a table/array in COBOL?

Ans:

01 ARRAYS.

05 ARRAY1 PIC X(9) OCCURS 10 TIMES.

05 ARRAY2 PIC X(6) OCCURS 20 TIMES INDEXED BY WS-INDEX.

168. Can the OCCURS clause be at the 01 level?

Ans: No

169. A statically bound subprogram is called twice. What happens to working-storage variables?

Ans:The working-storage section is allocated at the start of the run-unit and any data items with VALUE clauses are initialized to the appropriate value at the time. When the subprogram is called the second time, a working-storage items persist in their last used state. However, if the program is specified with INITIAL on the PROGRAM-ID, working-storage section is reinitialized each time the program is entered.

170. Significance of the COMMON Attribute ?

Ans:COMMON attribute is used with nested COBOL programs. If it is not specified, other nested programs will not be able to access the program. PROGRAM-ID. Pgmname is COMMON PROGRAM.

171. In which division and section, the Special-names paragraph appears?

Ans: Environment division and Configuration Section.

172. What is the LOCAL-STORAGE SECTION?

Ans:Local-Storage is allocated each time the program is called and is de-allocated when the program returns via an EXIT PROGRAM, GOBACK, or STOP RUN. Any data items with a VALUE clauses are initialized to the appropriate value each time the program is called. The value in the data items is lost when the program returns. It is defined in the DATA DIVISION after WORKING-STORAGE SECTION

173. What does passing BY REFERENCE mean?

Ans:When the data is passed between programs, the subprogram refers to and processes the data items in the calling program's storage, rather than working on a copy of the data. When

CALL . . . BY REFERENCE identifier. In this case, the caller and the called share the same memory.

174. What does passing BY CONTENT mean?

Ans:The calling program passes only the contents of the literal, or identifier. With a CALL . . . BY CONTENT, the called program cannot change the value of the literal or identifier in the calling program, even if it modifies the variable in which it received the literal or identifier.

175. What does passing BY VALUE mean?

Ans:The calling program or method is passing the value of the literal, or identifier, not a reference to the sending data item. The called program or invoked method can change the parameter in the called program or invoked method. However, because the subprogram or method has access only to a temporary copy of the sending data item, those changes do not affect the argument in the calling program. Use By value, If you want to pass data to C program. Parameters must be of certain data type.

176. What is the default, passing BY REFERENCE or passing BY CONTENT or passing BY VALUE?

Ans: Passing by reference (the caller and the called share the same memory).

177. Where do you define your data in a program if the data is passed to the program from a Caller program?

Ans: Linkage Section

Core Java Interview Questions Part-7

91 Q What is java byte code?

Byte code is an sort of intermediate code. The byte code is processed by virtual machine.

92 Q What is method overloading?

Method overloading is the process of creating a new method with the same name and different signature.

93 Q What is method overriding?

Method overriding is the process of giving a new definition for an existing method in its child class.

94 Q What is finalize() ?

Finalize is a protected method in java. When the garbage collector is executes , it will first call finalize( ), and on the next garbage-collection it reclaim the objects memory. So finalize( ), gives you the chance to perform some cleanup operation at the time of garbage collection.

95 Q What is multi-threading?

Multi-threading is the scenario where more than one threads are running.

96 Q What is deadlock?

Deadlock is a situation when two threads are waiting on each other to release a resource. Each thread waiting for a resource which is held by the other waiting thread.

97 Q What is the difference between Iterator and Enumeration?

Iterator differ from enumeration in two ways Iterator allow the caller to remove elements from the underlying collection during the iteration with well-defined semantics. And , method names have been improved.

98 Q What is the Locale class?

A Locale object represents a specific geographical, political, or cultural region

99 Q What is internationalization?

Internationalization is the process of designing an application so that it can be adapted to various languages and regions without changes.

100 Q What is anonymous class ?

A An anonymous class is a type of inner class that don't have any name.

101 Q What is the difference between URL and URLConnection?

A URL represents the location of a resource, and a URLConnection represents a link for accessing or communicating with the resource at the location.

102 Q What are the two important TCP Socket classes?

ServerSocket and Socket. ServerSocket is useful for two-way socket communication. Socket class help us to read and write through the sockets. getInputStream() and getOutputStream() are the two methods available in Socket class.

103 Q Strings are immutable. But String s="Hello"; String s1=s+"World" returns HelloWorld how ?

Here actually a new object is created with the value of HelloWorld

104 Q What is classpath?

Classpath is the path where Java looks for loading class at run time and compile time.

105 Q What is path?

It is an the location where the OS will look for finding out the executable files and commands.

106 Q What is java collections?

Java collections is a set of classes, that allows operations on a collection of classes.

107 Q Can we compile a java program without main?

Yes, we can. In order to compile a java program, we don't require any main method. But to execute a java program we must have a main in it (unless it is an applet or servlet). Because main is the starting point of a java program.

108 Q What is a java compilation unit.

A compilation unit is a java source file.

109 What are the restrictions when overriding a method ?

Overridden methods must have the same name, argument list, and return type (i.e., they must have the exact signature of the method we are going to override, including return type.) The overriding method cannot be less visible than the method it overrides( i.e., a public method cannot be override to private). The overriding method may not throw any exceptions that may not be thrown by the overridden method

110 Q What is static initializer block? What is its use?

A static initializer block is a block of code that declares with the static keyword. It normally contains the block of code that must execute at the time of class loading. The static initializer block will execute only once at the time of loading the class only.

Core Java Interview Questions Part-8

111 Q How does a try statement determine which catch clause should be used to handle an exception?

When an exception is thrown , the catch block of the try statement are examined in the order in which they appear. The first catch block that is capable of handling the exception is executed. The remaining catch blocks are ignored

112 Q How parameters are passed to methods in java program ?

All java method parameters in java are passed by value only. Obviously primitives are passed by value. In case of objects a copy of the reference is passed and so all the changes made in the method will persist.

113 Q If a class doesn't have any constructors, what will happen?

If a class doesn't have a constructor, the JVM will provide a default constructor for the class.

114 Q What will happen if a thread cannot acquire a lock on an object?

It enters to the waiting state until lock becomes available.

115 Q How does multithreading occurring on a computer with a single CPU?

The task scheduler of OS allocates an execution time for multiple tasks. By switching between different executing tasks, it creates the impression that tasks execute sequentially. But actually there is only one task is executed at a time.

116 Q What will happen if you are invoking a thread's interrupt method while the thread is waiting or sleeping?

When the task enters to the running state, it will throw an InterruptedException.

117 Q What are the different ways in which a thread can enter into waiting state?

There are three ways for a thread to enter into waiting state. By invoking its sleep() method, by blocking on I/O, by unsuccessfully attempting to acquire an object's lock, or by invoking an object's wait() method.

118 Q What are the the different ways for creating a thread?

A thread can be created by subclassing Thread, or by implementing the Runnable interface.

119 Q What is the difference between creating a thread by extending Thread class and by implementing Runnable interface? Which one should prefer?

When creating a thread by extending the Thread class, it is not mandatory to override the run method (If we are not overriding the run method , it is useless), because Thread class have already given a default implementation for run method. But if we are implementing Runnable , it is mandatory to override the run method. The preferred way to create a thread is by implementing Runnable interface, because it give loose coupling.

120 Q What is coupling?

Coupling is the dependency between different components of a system

121 Q How is an interface?

An interface is a collection of method declarations and constants. In java interfaces are used to achieve multiple inheritance. It sets a behavioral protocol to all implementing classes.

122 Q What is an abstract class?

An abstract class is an incomplete class. An abstract class is defined with the keyword abstract . We cannot create an object of the abstract class because it is not complete. It sets a behavioral protocol for all its child classes.

123 Q How will you define an interface?

An interface is defined with the keyword interface. Eg:
public interface MyInterface { }

124 Q How will you define an abstract class?

An abstract class is defined with the keyword abstract Eg:
public abstract class MyClass { }

125 Q What is any an anonymous class?

A An anonymous class is a local class with no name.

126 Q What is a JVM heap?

The heap is the runtime data area from which memory for all class instances and arrays is allocated. The heap may be of a fixed size or may be expanded. The heap is created on virtual machine start-up.

127 Q What is difference between string and StringTokenizer?

StringTokenizer as its name suggests tokenizes a String supplied to it as an argument to its constructor and the character based on which tokens of that string are to be made. The default tokenizing character is space " ".

128 Q What is the difference between array and ArrayList ?

Array is collection of same data type. Array size is fixed, It cannot be expanded. But ArrayList is a growable collection of objects. ArrayList is a part of Collections Framework and can work with only objects.

129 Q What is difference between java.lang .Class and java.lang.ClassLoader? What is the hierarchy of ClassLoader ?

Class 'java.lang.Class' represent classes and interfaces in a running Java application. JVM construct 'Class' object when class in loaded. Where as a ClassLoader is also a class which loads the class files into memory in order for the Java programs to execute properly. The hierarchy of ClassLoaders is:

Bootstrap ClassLoaders
Extensive ClassLoaders
System Classpath ClassLoaders
Application ClassLoaders

130 Q What is daemon thread?

Theards which are running on the background are called deamon threads. daemon thread is a thread which doesn't give any chance to run other threads once it enters into the run state it doesn't give any chance to run other threads. Normally it will run forever, but when all other non-daemon threads are dead, daemon thread will be killed by JVM

131 Q What is a green thread?

Native threads can switch between threads preemptively. Green threads switch only when control is explicitly given up by a thread ( Thread.yield(), Object.wait(), etc.) or a thread performs a blocking operation (read(), etc.). On multi-CPU machines, native threads can run more than one thread simultaneously by assigning different threads to different CPUs. Green threads run on only one CPU. Native threads create the appearance that many Java processes are running: each thread takes up its own entry in the process table. One clue that these are all threads of the same process is that the memory size is identical for all the threads - they are all using the same memory. The process table is not infinitely large, and processes can only create a limited number of threads before running out of system resources or hitting configured limits.