What is primary allocation for a dataset?
The space allocated when the dataset is first created.
What is the difference between primary and secondary allocations for a
dataset?
Secondary allocation is done when more space is required than what has
already been allocated.
How many extents are possible for a sequential file ? For a VSAM file ?
16 extents on a volume for a sequential file and 123 for a VSAM file.
What does a disposition of (NEW,CATLG,DELETE) mean?
That this is a new dataset and needs to be allocated, to CATLG the
dataset if the step is successful and to delete the dataset if the step
abends.
What does a disposition of (NEW,CATLG,KEEP) mean?
That this is a new dataset and needs to be allocated, to CATLG the
dataset if the step is successful and to KEEP but not CATLG the dataset
if the step abends. Thus if the step abends, the dataset would not be
catalogued and we would need to supply the vol. ser the next time we
refer to it.
How do you access a file that had a disposition of KEEP?
Need to supply volume serial no. VOL=SER=xxxx.
What does a disposition of (MOD,DELETE,DELETE) mean ?
The MOD will cause the dataset to be created (if it does not exist), and
then the two DELETEs will cause the dataset to be deleted whether the
step abends or not. This disposition is used to clear out a dataset at
the beginning of a job.
What is the DD statement for a output file?
Unless allocated earlier, will have the foll parameters:
DISP=(NEW,CATLG,DELETE), UNIT , SPACE & DCB .
What do you do if you do not want to keep all the space allocated to a
dataset?
Specify the parameter RLSE ( release ) in the SPACE e.g.
SPACE=(CYL,(50,50),RLSE)
What is DISP=(NEW,PASS,DELETE)?
This is a new file and create it, if the step terminates normally, pass
it to the subsequent steps and if step abends, delete it. This dataset
will not exist beyond the JCL.
How do you create a temporary dataset? Where will you use them?
Temporary datasets can be created either by not specifying any DSNAME or
by specifying the temporary file indicator as in DSN=&&TEMP.
We use them to carry the output of one step to another step in the same
job. The dataset will not be retained once the job completes.
How do you restart a proc from a particular step?
In job card, specify RESTART=procstep.stepname
where procstep = name of the jcl step that invoked the proc
and stepname = name of the proc step where you want execution to start
How do you skip a particular step in a proc/JOB?
Can use either condition codes or use the jcl control statement IF (only
in ESA JCL)
A PROC has five steps. Step 3 has a condition code. How can you
override/nullify this condition code?
Provide the override on the EXEC stmt in the JCL as follows:
//STEP001 EXEC procname,COND.stepname=value
All parameters on an EXEC stmt in the proc such as COND, PARM have to be
overridden like this.
How do you override a specific DDNAME/SYSIN in PROC from a JCL?
//
What is NOTCAT 2 ?
This is an MVS message indicating that a duplicate catalog entry exists.
E.g., if you already have a dataset with dsn = ‘xxxx.yyyy’ and u try to
create one with disp new,catlg, you would get this error. the program
open and write would go through and at the end of the step the system
would try to put it in the system catalog. at this point since an entry
already exists the catlg would fail and give this message. you can fix
the problem by deleting/uncataloging the first data set and going to the
volume where the new dataset exists(this info is in the msglog of the
job) and cataloging it.
What is 'S0C7' abend?
Caused by invalid data in a numeric field.
What is a S0C4 error ?
Storage violation error - can be due to various reasons. e.g.: READING a
file that is not open, invalid address referenced due to subscript error.
What are SD37, SB37, SE37 abends?
All indicate dataset out of space. SD37 - no secondary allocation was
specified. SB37 - end of vol. and no further volumes specified. SE37 -
Max. of 16 extents already allocated.
What is S322 abend ?
Indicates a time out abend. Your program has taken more CPU time than the
default limit for the job class. Could indicate an infinite loop.
Why do you want to specify the REGION parameter in a JCL step?
To override the REGION defined at the JOB card level.
REGION specifies the max region size. REGION=0K or 0M or omitting REGION
means no limit will be applied.
What does the TIME parameter signify ? What does TIME=1440 mean ?
TIME parameter can be used to overcome S322 abends for programs that
genuinely need more CPU time. TIME=1440 means no CPU time limit is to be
applied to this step.
What is COND=EVEN ?
Means execute this step even if any of the previous steps, terminated
abnormally.
What is COND=ONLY ?
Means execute this step only if any of the previous steps, terminated
abnormally.
How do you check the syntax of a JCL without running it?
TYPERUN=SCAN on the JOB card or use JSCAN.
JCL interview questions and answers
DB2 interview questions and answers
How would you find out the total number of rows in a DB2 table?
Use SELECT COUNT(*) ... in db2 query
How do you eliminate duplicate values in DB2 SELECT ?
Use SELECT DISTINCT ... in db2 query
How do you select a row using indexes in DB2?
Specify the indexed columns in the WHERE clause of db2 query.
How do you find the maximum value in a column in db2?
Use SELECT MAX(...) .. in db2 query
How do you retrieve the first 5 characters of FIRSTNAME column of DB2 table EMP ?
SQL Query : SELECT SUBSTR(FIRSTNAME,1,5) FROM EMP;
What are aggregate functions?
Bulit-in mathematical functions for use in SELECT clause.
Can you use MAX on a CHAR column?
YES.
My SQL statement SELECT AVG(SALARY) FROM EMP yields inaccurate results. Why?
Because SALARY is not declared to have NULLs and the employees for whom the salary is not known are also counted.
How do you concatenate the FIRSTNAME and LASTNAME from EMP table to give a complete name?
SELECT FIRSTNAME ‘ ‘ LASTNAME FROM EMP;
What is the use of VALUE function?
1. Avoid -ve SQLCODEs by handling nulls and zeroes in computations
2. Substitute a numeric value for any nulls used in computation
What is UNION,UNION ALL? –
UNION : eliminates duplicates
UNION ALL: retains duplicates
Both these are used to combine the results of different SELECT statements.
Suppose I have five SQL SELECT statements connected by UNION/UNION ALL, how many times should I specify UNION to eliminate the duplicate rows? -
Once.
What is the restriction on using UNION in embedded SQL?
It has to be in a CURSOR.
In the WHERE clause what is BETWEEN and IN? –
BETWEEN supplies a range of values while IN supplies a list of values.
Is BETWEEN inclusive of the range values specified? –
Yes.
What is 'LIKE' used for in WHERE clause? What are the wildcard characters? –
LIKE is used for partial string matches. ‘%’ ( for a string of any character ) and ‘_’ (for any single character ) are the two wild card characters.
When do you use a LIKE statement?
To do partial search e.g. to search employee by name, you need not specify the complete name; using LIKE, you can search for partial string matches.
What is the meaning of underscore ( ‘_’ ) in the LIKE statement? –
Match for any single character.
What do you accomplish by GROUP BY ... HAVING clause? –
GROUP BY partitions the selected rows on the distinct values of the column on which you group by.
HAVING selects GROUPs which match the criteria specified
Consider the employee table with column PROJECT nullable. How can you get a list of employees who are not assigned to any project?
SELECT EMPNO
FROM EMP
WHERE PROJECT IS NULL;
What is the result of this query if no rows are selected:
SELECT SUM(SALARY)
FROM EMP
WHERE QUAL=‘MSC’;
NULL
Why SELECT * is not preferred in embedded SQL programs?
For three reasons:
If the table structure is changed ( a field is added ), the program will have to be modified
Program might retrieve the columns which it might not use, leading on I/O over head.
The chance of an index only scan is lost.
What are correlated subqueries? -
A subquery in which the inner ( nested ) query refers back to the table in the outer query. Correlated subqueries must be evaluated for each qualified row of the outer query that is referred to.
What is a cursor? why should it be used? –
Cursor is a programming device that allows the SELECT to find a set of rows but return them one at a time.
Cursor should be used because the host language can deal with only one row at a time.
How would you retrieve rows from a DB2 table in embedded SQL? –
Either by using the single row SELECT statements, or by using the CURSOR.
Apart from cursor, what other ways are available to you to retrieve a row from a table in embedded SQL? -
Single row SELECTs.
Where would you specify the DECLARE CURSOR statement? –
See answer to next question.
How do you specify and use a cursor in a COBOL program? –
Use DECLARE CURSOR statement either in working storage or in procedure division(before open cursor), to specify the SELECT statement. Then use OPEN, FETCH rows in a loop and finally CLOSE.
What happens when you say OPEN CURSOR?
If there is an ORDER BY clause, rows are fetched, sorted and made available for the FETCH statement. Other wise simply the cursor is placed on the first row.
Is DECLARE CURSOR executable?
No.
Can you have more than one cursor open at any one time in a program ? –
Yes.
When you COMMIT, is the cursor closed? -
Yes.
How do you leave the cursor open after issuing a COMMIT? ( for DB2 2.3 or above only )
Use WITH HOLD option in DECLARE CURSOR statement. But, it has not effect in psuedo-conversational CICS programs.
Give the COBOL definition of a VARCHAR field.
A VARCHAR column REMARKS would be defined as follows:
...
10 REMARKS.
49 REMARKS-LEN PIC S9(4) USAGE COMP.
49 REMARKS-TEXT PIC X(1920).
What is the physical storage length of each of the following DB2 data types:
DATE, TIME, TIMESTAMP?
DATE: 4bytes
TIME: 3bytes
TIMESTAMP: 10bytes
What is the COBOL picture clause of the following DB2 data types:
DATE, TIME, TIMESTAMP?
DATE: PIC X(10)
TIME : PIC X(08)
TIMESTAMP: PIC X(26)
What is the COBOL picture clause for a DB2 column defined as DECIMAL(11,2)? -
PIC S9(9)V99 COMP-3.
Note: In DECIMAL(11,2), 11 indicates the size of the data type and 2 indicates the precision.
What is DCLGEN ? -
DeCLarations GENerator: used to create the host language copy books for the table definitions. Also creates the DECLARE table.
What are the contents of a DCLGEN? -
1. EXEC SQL DECLARE TABLE statement which gives the layout of the table/view in terms of DB2 datatypes.
2. A host language copy book that gives the host variable definitions for the column names.
Is it mandatory to use DCLGEN? If not, why would you use it at all? -
It is not mandatory to use DCLGEN.
Using DCLGEN, helps detect wrongly spelt column names etc. during the pre-compile stage itself ( because of the DECLARE TABLE ). DCLGEN being a tool, would generate accurate host variable definitions for the table reducing chances of error.
Is DECLARE TABLE in DCLGEN necessary? Why it used?
It not necessary to have DECLARE TABLE statement in DCLGEN. This is used by the pre-compiler to validate the table-name, view-name, column name etc., during pre-compile.
Will precompile of an DB2-COBOL program bomb, if DB2 is down?
No. Because the precompiler does not refer to the DB2 catalogue tables.
How is a typical DB2 batch pgm executed ?
1. Use DSN utility to run a DB2 batch program from native TSO. An example is shown:
DSN SYSTEM(DSP3)
RUN PROGRAM(EDD470BD) PLAN(EDD470BD) LIB('ED 01T.OBJ.LOADLIB')
END
2. Use IKJEFT01 utility program to run the above DSN command in a JCL.
Assuming that a site’s standard is that pgm name = plan name, what is the easiest way to find out which pgms are affected by change in a table’s structure ?
Query the catalogue tables SYSPLANDEP and SYSPACKDEP.
Name some fields from SQLCA.
SQLCODE, SQLERRM, SQLERRD
How can you quickly find out the # of rows updated after an update statement?
Check the value stored in SQLERRD(3).
What is EXPLAIN? –
EXPLAIN is used to display the access path as determined by the optimizer for a SQL statement. It can be used in SPUFI (for single SQL statement ) or in BIND step (for embedded SQL ).
What do you need to do before you do EXPLAIN?
Make sure that the PLAN_TABLE is created under the AUTHID.
Where is the output of EXPLAIN stored? –
In userid.PLAN_TABLE
EXPLAIN has output with MATCHCOLS = 0. What does it mean? –
a nonmatching index scan if ACCESSTYPE = I.
How do you do the EXPLAIN of a dynamic SQL statement?
1. Use SPUFI or QMF to EXPLAIN the dynamic SQL statement
2. Include EXPLAIN command in the embedded dynamic SQL statements
How do you simulate the EXPLAIN of an embedded SQL statement in SPUFI/QMF? Give an example with a host variable in WHERE clause.)
Use a question mark in place of a host variable ( or an unknown value ). e.g.
SELECT EMP_NAME
FROM EMP
WHERE EMP_SALARY > ?
What are the isolation levels possible ? –
CS: Cursor Stability
RR: Repeatable Read
What is the difference between CS and RR isolation levels?
CS: Releases the lock on a page after use
RR: Retains all locks acquired till end of transaction
Where do you specify them ?
ISOLATION LEVEL is a parameter for the bind process.
I use CS and update a page. Will the lock be released after I am done with that page?
No.
What are the various locking levels available?
PAGE, TABLE, TABLESPACE
How does DB2 determine what lock-size to use?
1. Based on the lock-size given while creating the tablespace
2. Programmer can direct the DB2 what lock-size to use
3. If lock-size ANY is specified, DB2 usually chooses a lock-size of PAGE
What are the disadvantages of PAGE level lock?
High resource utilization if large updates are to be done
What is lock escalation?
Promoting a PAGE lock-size to table or tablespace lock-size when a transaction has acquired more locks than specified in NUMLKTS. Locks should be taken on objects in single tablespace for escalation to occur.
What are the various locks available?
SHARE, EXCLUSIVE, UPDATE
Can I use LOCK TABLE on a view?
No. To lock a view, take lock on the underlying tables.
What is ALTER ? –
SQL command used to change the definition of DB2 objects.
What is a DBRM, PLAN ?
DBRM: DataBase Request Module, has the SQL statements extracted from the host language program by the pre-compiler.
PLAN: A result of the BIND process. It has the executable code for the SQL statements in the DBRM.
What is ACQUIRE/RELEASE in BIND?
Determine the point at which DB2 acquires or releases locks against table and tablespaces, including intent locks.
What else is there in the PLAN apart from the access path? –
PLAN has the executable code for the SQL statements in the host program
What happens to the PLAN if index used by it is dropped?
Plan is marked as invalid. The next time the plan is accessed, it is rebound.
What are PACKAGES ? –
They contain executable code for SQL statements for one DBRM.
What are the advantages of using a PACKAGE?
1. Avoid having to bind a large number of DBRM members into a plan
2. Avoid cost of a large bind
3. Avoid the entire transaction being unavailable during bind and automatic rebind of a plan
4. Minimize fallback complexities if changes result in an error.
What is a collection?
a user defined name that is the anchor for packages. It has not physical existence. Main usage is to group packages.
In SPUFI suppose you want to select max. of 1000 rows , but the select returns only 200 rows.
What are the 2 sqlcodes that are returned? –
100 ( for successful completion of the query ), 0 (for successful COMMIT if AUTOCOMMIT is set to Yes).
How would you print the output of an SQL statement from SPUFI? –
Print the output dataset.
How do you pull up a query which was previously saved in QMF ? –
??
Lot of updates have been done on a table due to which indexes have gone haywire. What do you do? –
Looks like index page split has occurred. DO a REORG of the indexes.
What is dynamic SQL? –
Dynamic SQL is a SQL statement created at program execution time.
When is the access path determined for dynamic SQL? –
At run time, when the PREPARE statement is issued.
Suppose I have a program which uses a dynamic SQL and it has been performing well till now. Off late, I find that the performance has deteriorated. What happened? –
Probably RUN STATS is not done and the program is using a wrong index due to incorrect stats.
Probably RUNSTATS is done and optimizer has chosen a wrong access path based on the latest statistics.
How does DB2 store NULL physically?
as an extra-byte prefix to the column value. physically, the nul prefix is Hex ’00’ if the value is present and Hex ‘FF’ if it is not.
How do you retrieve the data from a nullable column? –
Use null indicators. Syntax ... INTO :HOSTVAR:NULLIND
What is the picture clause of the null indicator variable? –
S9(4) COMP.
What does it mean if the null indicator has -1, 0, -2? –
-1 : the field is null
0 : the field is not null
-2 : the field value is truncated
How do you insert a record with a nullable column?
To insert a NULL, move -1 to the null indicator
To insert a valid value, move 0 to the null indicator
What is RUNSTATS? –
A DB2 utility used to collect statistics about the data values in tables which can be used by the optimizer to decide the access path. It also collects statistics used for space management. These statistics are stored in DB2 catalog tables.
When will you chose to run RUNSTATS?
After a load, or after mass updates, inserts, deletes, or after REORG.
Give some example of statistics collected during RUNSTATS?
# of rows in the table
Percent of rows in clustering sequence
# of distinct values of indexed column
# of rows moved to a nearby/farway page due to row length increase
What is REORG? When is it used?
REORG reorganizes data on physical storage to reclutser rows, positioning overflowed rows in their proper sequence, to reclaim space, to restore free space. It is used after heavy updates, inserts and delete activity and after segments of a segmented tablespace have become fragmented.
What is IMAGECOPY ? –
It is full backup of a DB2 table which can be used in recovery.
When do you use the IMAGECOPY? –
To take routine backup of tables
After a LOAD with LOG NO
After REORG with LOG NO
What is COPY PENDING status?
A state in which, an image copy on a table needs to be taken, In this status, the table is available only for queries. You cannot update this table. To remove the COPY PENDING status, you take an image copy or use REPAIR utility.
What is CHECK PENDING ?
When a table is LOADed with ENFORCE NO option, then the table is left in CHECK PENDING status. It means that the LOAD utility did not perform constraint checking.
What is QUIESCE?
A QUIESCE flushes all DB2 buffers on to the disk. This gives a correct snapshot of the database and should be used before and after any IMAGECOPY to maintain consistency.
What is a clustering index ? –
Causes the data rows to be stored in the order specified in the index. A mandatory index defined on a partitioned table space.
How many clustering indexes can be defined for a table?
Only one.
What is the difference between primary key & unique index ?
Primary : a relational database constraint. Primary key consists of one or more columns that uniquely identify a row in the table. For a normalized relation, there is one designated primary key.
Unique index: a physical object that stores only unique values. There can be one or more unique indexes on a table.
What is sqlcode -922 ?
Authorization failure
What is sqlcode -811?
SELECT statement has resulted in retrieval of more than one row.
What does the sqlcode of -818 pertain to? –
This is generated when the consistency tokens in the DBRM and the load module are different.
Are views updateable ?
Not all of them. Some views are updateable e.g. single table view with all the fields or mandatory fields. Examples of non-updateable views are views which are joins, views that contain aggregate functions(such as MIN), and views that have GROUP BY clause.
If I have a view which is a join of two or more tables, can this view be updateable? –
No.
What are the 4 environments which can access DB2 ?
TSO, CICS, IMS and BATCH
What is an inner join, and an outer join ?
Inner Join: combine information from two or more tables by comparing all values that meet the search criteria in the designated column or columns of on e table with all the clause in corresponding columns of the other table or tables. This kind of join which involve a match in both columns are called inner joins.
Outer join is one in which you want both matching and non matching rows to be returned. DB2 has no specific operator for outer joins, it can be simulated by combining a join and a correlated sub query with a UNION.
What is FREEPAGE and PCTFREE in TABLESPACE creation?
PCTFREE: percentage of each page to be left free
FREEPAGE: Number of pages to be loaded with data between each free page
What are simple, segmented and partitioned table spaces ?
Simple Tablespace:
Can contain one or more tables
Rows from multiple tables can be interleaved on a page under the DBAs control and maintenance
Segmented Tablespace:
Can contain one or more tables
Tablespace is divided into segments of 4 to 64 pages in increments of 4 pages. Each segment is dedicated to single table. A table can occupy multiple segments
Partitioned Tablespace:
Can contain one table
Tablespace is divided into parts and each part is put in a separate VSAM dataset.
What is filter factor?
one divided by the number of distinct values of a column.
What is index cardinality? –
The number of distinct values a column or columns contain.
What is a synonym ?
Synonym is an alternate name for a table or view used mainly to hide the leading qualifier of a table or view.. A synonym is accessible only by the creator.
What is the difference between SYNONYM and ALIAS?
SYNONYM: is dropped when the table or tablespace is dropped. Synonym is available only to the creator.
ALIAS: is retained even if table or tablespace is dropped. ALIAS can be created even if the table does not exist. It is used mainly in distributed environment to hide the location info from programs. Alias is a global object & is available to all.
What do you mean by NOT NULL WITH DEFAULT? When will you use it?
This column cannot have nulls and while insertion, if no value is supplied then it wil have zeroes, spaces or date/time depending on whether it is numeric, character or date/time.
Use it when you do not want to have nulls but at the same time cannot give values all the time you insert this row.
What do you mean by NOT NULL? When will you use it?
The column cannot have nulls. Use it for key fields.
When would you prefer to use VARCHAR?
When a column which contains long text, e.g. remarks, notes, may have in most cases less than 50% of the maximum length.
What are the disadvantages of using VARCHAR?
1. Can lead to high space utilization if most of the values are close to maximum.
2. Positioning of VARCHAR column has to be done carefully as it has performance implications.
3. Relocation of rows to different pages can lead to more I/Os on retrieval.
How do I create a table MANAGER ( EMP#, MANAGER) where MANAGER is a foreign key which references to EMP# in the same table? Give the exact DDL.
First CREATE MANAGER table with EMP# as the primary key. Then ALTER it to define the foreign key.
When is the authorization check on DB2 objects done - at BIND time or run time?
At run time.
What is auditing?
Recording SQL statements that access a table. Specified at table creation time or through alter.
Swing interview questions and answers
What is JFC?
JFC stands for Java Foundation Classes. The Java Foundation Classes (JFC) are a set of Java class libraries provided as part of Java 2 Platform, Standard Edition (J2SE) to support building graphics user interface (GUI) and graphics functionality for client applications that will run on popular platforms such as Microsoft Windows, Linux, and Mac OSX.
What is AWT?
AWT stands for Abstract Window Toolkit. AWT enables programmers to develop Java applications with GUI components, such as windows, and buttons. The Java Virtual Machine (JVM) is responsible for translating the AWT calls into the appropriate calls to the host operating system
What are the differences between Swing and AWT?
AWT is heavy-weight components, but Swing is light-weight components. AWT is OS dependent because it uses native components, But Swing components are OS independent. We can change the look and feel in Swing which is not possible in AWT. Swing takes less memory compared to AWT. For drawing AWT uses screen rendering where Swing uses double buffering.
What are heavyweight components ?
A heavyweight component is one that is associated with its own native screen resource (commonly known as a peer
What is lightweight component?
A lightweight component is one that "borrows" the screen resource of an ancestor (which means it has no native resource of its own -- so it's "lighter
What is double buffering ?
Double buffering is the process of use of two buffers rather than one to temporarily hold data being moved to and from an I/O device. Double buffering increases data transfer speed because one buffer can be filled while the other is being emptied.
What is an event?
Changing the state of an object is called an event
What is an event handler ?
An event handler is a part of a computer program created to tell the program how to act in response to a specific event
What is a layout manager?
A layout manager is an object that is used to organize components in a container.
What is clipping?
Clipping is the process of confining paint operations to a limited area or shape
Which containers use a border Layout as their default layout
The window, Frame and Dialog classes use a border layout as their default layout.
What is the preferred size of a component?
The preferred size of a component is the minimum component size that will allow the component to display normally.
What method is used to specify a container's layout
The setLayout() method is used to specify a container's layout.
Which containers use a FlowLayout as their default layout?
The Panel and Applet classes use the FlowLayout as their default layout.
Which method of the Component class is used to set the position and size of a component?
setBounds
What is the difference between invokeAndWait() and invokeLater()?
invokeAndWait is synchronous. It blocks until Runnable task is complete. InvokeLater is asynchronous. It posts an action event to the event queue and returns immediately. It will not wait for the task to complete
Why should any swing call back implementation execute quickly?
Callbacks are invoked by the event dispatch thread. Event dispatch thread blocks processing of other events as long as call back method executes.
What is an applet?
Applet is a java program that runs inside a web browser.
What is the difference between applications and applets?
Application must be run explicitly within Java Virtual Machine whereas applet loads and runs itself automatically in a java-enabled browser. Application starts execution with its main method whereas applet starts execution with its init method. Application can run with or without graphical user interface whereas applet must run within a graphical user interface. In order to run an applet we need a java enabled web browser or an appletviewer.
Which method is used by the applet to recognize the height and width?
getParameters().
When we should go for codebase in applet
If the applet class is not in the same directory, codebase is used.
What is the lifecycle of an applet?
init( ) method - called when an applet is first loadedstart( ) method - called each time an applet is startedpaint( ) method - called when the applet is minimized or maximizedstop( ) method - called when the browser moves off the applet's pagedestroy( ) method - called when the browser is finished with the applet
Which method is used for setting security in applets?
setSecurityManager
What is an event and what are the models available for event handling?
Changing the state of an object is called an event. An event is an event object that describes a state of change. In other words, event occurs when an action is generated, like pressing a key on keyboard, clicking mouse, etc. There different types of models for handling events are event-inheritance model and event-delegation model
What are the advantages of the event-delegation model over the event-inheritance model
Event-delegation model has two advantages over event-inheritance model. a)Event delegation model enables event handling by objects other than the ones that generate the events. This allows a clean separation between a component's design and its use. b)It performs much better in applications where many events are generated. This performance improvement is due to event-delegation model does not have to be repeatedly process unhandled events as is the case of the event-inheritance.
What is source and listener
A source is an object that generates an event. This occurs when the internal state of that object changes in some way. A listener is an object that is notified when an event occurs. It has two major requirements. First, it must have been registered with a source to receive notifications about specific event. Second, it must implement necessary methods to receive and process these notifications.
What is controls and what are different types of controls in AWT?
Controls are components that allow a user to interact with your application. AWT supports the following types of controls: Labels, Push Buttons, Check Boxes, Choice Lists, Lists, Scrollbars, Text Components. These controls are subclasses of Component.
What is the difference between choice and list?
A Choice is displayed in a compact form that requires you to pull it down to see the list of available choices and only one item may be selected from a choice. A List may be displayed in such a way that several list items are visible and it supports the selection of one or more list items.
What is the difference between scrollbar and scrollpane?
A Scrollbar is a Component, but not a Container whereas Scrollpane is a Container and handles its own events and perform its own scrolling.
What is a layout manager and what are different types of layout managers available?
A layout manager is an object that is used to organize components in a container. The different layouts are available are FlowLayout, BorderLayout, CardLayout, GridLayout , GridBagLayout, Boxlayout and SpringLayout
How are the elements of different layouts organized?
The elements of a FlowLayout are organized in a top to bottom, left to right fashion. The elements of a BorderLayout are organized at the borders (North, South, East and West) and the center of a container. The elements of a CardLayout are stacked, on top of the other, like a deck of cards. The elements of a GridLayout are of equal size and are laid out using the square of a grid. The elements of a GridBagLayout are organized according to a grid. However, the elements are of different size and may occupy more than one row or column of the grid. In addition, the rows and columns may have different sizes. It is the most flexible layout.
What are types of applets?
There are two different types of applets. Trusted Applets and Untrusted applets. Trusted Applets are applets with predefined security and Untrusted Applets are applets without any security.
What are the restrictions imposed by a Security Manager on Applets?
Applets cannot read or write files on the client machine that's executing it. They cannot load libraries or access native libraries. They cannot make network connections except to the host that it came from. They cannot start any program on the client machine. They cannot read certain system properties. Windows that an applet brings up look different than windows that an application brings up.
What is the difference between the Font and FontMetrics classes?
The FontMetrics class is used to define implementation-specific properties, such as ascent and descent, of a Font object.
What is the relationship between an event-listener interface and an event-adapter class?
An event-listener interface defines the methods that must be implemented by an event handler for a particular kind of event. An event adapter provides a default implementation of an event-listener interface.
How can a GUI component handle its own events?
A component can handle its own events by implementing the required event-listener interface and adding itself as its own event listener.
What is the difference between the paint() and repaint() methods
The paint() method supports painting via a Graphics object. The repaint() method is used to cause paint() to be invoked by the AWT painting thread.
What interface is extended by AWT event listeners?
All AWT event listeners extend the java.util.EventListener interface.
What is Canvas ?
Canvas is a Component subclass which is used for drawing and painting. Canvas is a rectangular area where the application can draw or trap input events.
What is default Look-and-Feel of a Swing Component?
Java Look-and-Feel.
What are the features of JFC?
Pluggable Look-and-Feel, Accessibility API, Java 2D API, Drag and Drop Support.
What does x mean in javax.swing?
Extension of java.
What are invisible components?
They are light weight components that perform no painting, but can take space in the GUI. This is mainly used for layout management.
What is the default layout for a ContentPane in JFC?
BorderLayout.
What does Realized mean?
Realized mean that the component has been painted on screen or that is ready to be painted. Realization can take place by invoking any of these methods. setVisible(true), show() or pack().
What is difference between Swing and JSF?
The key difference is that JSF runs on server. It needs a server like Tomcat or WebLogic or WebSphere. It displays HTML to the client. But Swing program is a stand alone application.
Why does JComponent class have add() and remove() methods but Component class does not?
JComponent is a subclass of Container and can contain other components and JComponents.
What method is used to specify a container's layout?
The setLayout() method is used to specify a container's layout.
What is the difference between AWT and SWT?
SWT (Standard Widget Toolkit) is a completely independent Graphical User Interface (GUI) toolkit from IBM. They created it for the creation of Eclipse Integrated Development Environment (IDE). AWT is from Sun Microsystems.
What is the difference between JFC & WFC?
JFC supports robust and portable user interfaces. The Swing classes are robust, compatible with AWT, and provide you with a great deal of control over a user interface. Since source code is available, it is relatively easy to extend the JFC to do exactly what you need it to do. But the number of third-party controls written for Swing is still relatively small. WFC runs only on the Windows (32-bit) user interface, and uses Microsoft extensions to Java for event handling and ActiveX integration. Because ActiveX components are available to WFC programs, there are theoretically more controls available for WFC than for JFC. In practice, however, most ActiveX vendors do not actively support WFC, so the number of controls available for WFC is probably smaller than for JFC. The WFC programming model is closely aligned with the Windows platform.
What is a convertor?
Converter is an application that converts distance measurements between metric and U.S units
What is the difference between a Canvas and a Scroll Pane?
Canvas is a component. ScrollPane is a container. Canvas is a rectangular area where the application can draw or trap input events. ScrollPane implements horizontal and vertical scrolling.
What is the purpose of the enableEvents() method?
The enableEvents() method is used to enable an event for a particular object. Normally, an event is enabled when a listener is added to an object for a particular event. The enableEvents() method is used by objects that handle events by overriding their event-dispatch methods.
What is the difference between a MenuItem and a CheckboxMenuItem?
The CheckboxMenuItem class extends the MenuItem class to support a menu item that may be checked or unchecked.
Which is the super class of all event classes?
The java.awt.AWTEvent class is the highest-level class in the AWT event-class hierarchy
How the Canvas class and the Graphics class are related?
A Canvas object provides access to a Graphics object via its paint() method.
What is the difference between a Window and a Frame?
The Frame class extends Window to define a main application window that can have a menu bar. A window can be modal.
What is the relationship between clipping and repainting?
When a window is repainted by the AWT painting thread, it sets the clipping regions to the area of the window that requires repainting.
What advantage do Java's layout managers provide over traditional windowing systems?
Java uses layout managers to lay out components in a consistent manner across all windowing platforms. Since Java's layout managers aren't tied to absolute sizing and positioning, they are able to accommodate platform-specific differences among windowing systems.
When should the method invokeLater() be used?
This method is used to ensure that Swing components are updated through the event-dispatching thread.
JMS interview questions and answers
What is JMS?
The Java Message Service (JMS) API is a messaging standard that allows application components based on the Java 2 Platform, Enterprise Edition (J2EE) to create, send, receive, and read messages. It enables distributed communication that is loosely coupled, reliable, and
What type messaging is provided by JMS?
Both synchronous and asynchronous are provided by JMS.
What is messaging
Messaging is a mechanism by which data can be passed from one application to another application
What are the advantages of JMS?
One of the principal advantages of JMS messaging is that it's asynchronous. Thus not all the pieces need to be up all the time for the application to function as a whole.
What is synchronous messaging?
Synchronous messaging involves a client that waits for the server to respond to a message. So if one end is down the entire communication will fail.
What is asynchronous messaging
Asynchronous messaging involves a client that does not wait for a message from the server. An event is used to trigger a message from a server. So even if the client is down , the messaging will complete successfully.
What is the difference between queue and topic
A topic is typically used for one to many messaging , while queue is used for one-to-one messaging. Topic .e. it supports publish subscribe model of messaging where queue supports Point to Point Messaging.
What is Stream Message
Stream messages are a group of java primitives. It contains some convenient methods for reading the data. However Stream Message prevents reading a long value as short. This is so because the Stream Message also writes the type information along with the value of the primitive type and enforces a set of strict conversion rules which actually prevents reading of one primitive type as another.
What is Map message?
map message contains name value Pairs. The values can be of type primitives and its wrappers. The name is a string.
What is text message?
Text messages contains String messages (since being widely used, a separate messaging Type has been supported) . It is useful for exchanging textual data and complex character data like XML.
What is object message ?
Object message contains a group of serializeable java object. So it allows exchange of Java objects between applications. sot both the applications must be Java applications.
What is Byte Message ?
Byte Messages contains a Stream of uninterrupted bytes. Byte Message contains an array of primitive bytes in it's payload. Thus it can be used for transfer of data between two applications in their native format which may not be compatible with other Message types. It is also useful where JMS is used purely as a transport between two systems and the message payload is opaque to the JMS client
What is the difference between Byte Message and Stream Message
Bytes Message stores data in bytes. Thus the message is one contiguous stream of bytes. While the Stream Message maintains a boundary between the different data types stored because it also stores the type information along with the value of the primitive being stored. Bytes Message allows data to be read using any type. Thus even if your payload contains a long value, you can invoke a method to read a short and it will return you something. It will not give you a semantically correct data but the call will succeed in reading the first two bytes of data. This is strictly prohibited in the Stream Message. It maintains the type information of the data being stored and enforces strict conversion rules on the data being read.
What is the Role of the JMS Provider?
The JMS provider handles security of the messages, data conversion and the client triggering. The JMS provider specifies the level of encryption and the security level of the message, the best data type for the non-JMS client.
What are the different parts of a JMS message ?
A JMS message contains three parts. a header, an optional properties and an optional body.
JDBC interview question and answer
JDBC technology is an API (included in both J2SE and J2EE releases) that provides cross-DBMS connectivity to a wide range of SQL databases and access to other tabular data sources, such as spreadsheets or flat files. With a JDBC technology-enabled driver, you can connect all corporate data even in a heterogeneous environment
A stored procedure is a set of statements/commands which reside in the database. The stored procedure is precompiled. Each Database has it's own stored procedure language
The JDBC Driver provides vendor-specific implementations of the abstract classes provided by the JDBC API. This driver is used to connect to the database.
First we need to create an instance of a JDBC driver or load JDBC drivers, then we need to register this driver with DriverManager class. Then we can open a connection. By using this connection , we can create a statement object and this object will help us to execute the query.
DriverManager is a class in java.sql package. It is the basic service for managing a set of JDBC drivers.
A table of data representing a database result set, which is usually generated by executing a statement that queries the database.
A ResultSet object maintains a cursor pointing to its current row of data. Initially the cursor is positioned before the first row. The next method moves the cursor to the next row, and because it returns false when there are no more rows in the ResultSet object, it can be used in a while loop to iterate through the result set.
Connection class represents a connection (session) with a specific database. SQL statements are executed and results are returned within the context of a connection.
A Connection object's database is able to provide information describing its tables, its supported SQL grammar, its stored procedures, the capabilities of this connection, and so on. This information is obtained with the getMetaData method
A class as loaded by the classloader
Connection pooling is a technique used for sharing server resources among requesting clients. Connection pooling increases the performance of Web applications by reusing active database connections instead of creating a new connection with every request. Connection pool manager maintains a pool of open database connections.
There are mainly four type of JDBC drivers available. They are:
Type 1 : JDBC-ODBC Bridge Driver - A JDBC-ODBC bridge provides JDBC API access via one or more ODBC drivers. Note that some ODBC native code and in many cases native database client code must be loaded on each client machine that uses this type of driver. Hence, this kind of driver is generally most appropriate when automatic installation and downloading of a Java technology application is not important. For information on the JDBC-ODBC bridge driver provided by Sun.
Type 2: Native API Partly Java Driver- A native-API partly Java technology-enabled driver converts JDBC calls into calls on the client API for Oracle, Sybase, Informix, DB2, or other DBMS. Note that, like the bridge driver, this style of driver requires that some binary code be loaded on each client machine.
Type 3: Network protocol Driver- A net-protocol fully Java technology-enabled driver translates JDBC API calls into a DBMS-independent net protocol which is then translated to a DBMS protocol by a server. This net server middleware is able to connect all of its Java technology-based clients to many different databases. The specific protocol used depends on the vendor. In general, this is the most flexible JDBC API alternative. It is likely that all vendors of this solution will provide products suitable for Intranet use. In order for these products to also support Internet access they must handle the additional requirements for security, access through firewalls, etc., that the Web imposes. Several vendors are adding JDBC technology-based drivers to their existing database middleware products.
Type 4: JDBC Net pure Java Driver - A native-protocol fully Java technology-enabled driver converts JDBC technology calls into the network protocol used by DBMSs directly. This allows a direct call from the client machine to the DBMS server and is a practical solution for Intranet access. Since many of these protocols are proprietary the database vendors themselves will be the primary source for this style of driver. Several database vendors have these in progress.
Type 4 (JDBC Net pure Java Driver) is the fastest JDBC driver. Type 1 and Type 3 drivers will be slower than Type 2 drivers (the database calls are make at least three translations versus two), and Type 4 drivers are the fastest (only one translation).
No. The JDBC-ODBC Bridge does not support multi threading. The JDBC-ODBC Bridge uses synchronized methods to serialize all of the calls that it makes to ODBC. Multi-threaded Java programs may use the Bridge, but they won't get the advantages of multi-threading.
Cold backup means all these files must be backed up at the same time, before the database is restarted. Hot backup (official name is 'online backup' ) is a backup taken of each tablespace while the database is running and is being accessed by the users
Data denormalization is reverse procedure, carried out purely for reasons of improving performance. It maybe efficient for a high-throughput system to replicate data for certain data
Connection Object has a method called setAutocommit ( boolean flag) . For handling our own transaction we can set the parameter to false and begin your transaction . Finally commit the transaction by calling the commit method.
EJB Interview Questions and answers
Enterprise JavaBeans (EJB) technology is the server-side component architecture for the Java 2 Platform, Enterprise Edition (J2EE) platform. EJB technology enables rapid and simplified development of distributed, transactional, secure and portable applications based on Java technology.
There are 3 types of enterprise beans, namely: Session bean, Entity beans and Message driven beans.
Session bean represents a single client inside the J2EE server. To access the application deployed in the server the client invokes methods on the session bean. The session bean performs the task shielding the client from the complexity of the business logic.
Session bean components implement the javax.ejb.SessionBean interface. Session beans can act as agents modeling workflow or provide access to special transient business services. Session beans do not normally represent persistent business concepts. A session bean corresponds to a client server session. The session bean is created when a client requests some query on the database and exists as long as the client server session exists.
There are two types of session beans, namely: Stateful and Stateless
Stateful session bean maintain the state of the conversation between the client and itself. When the client invokes a method on the bean the instance variables of the bean may contain a state but only for the duration of the invocation.
A stateful session bean is an enterprise bean (EJB component) that acts as a server-side extension of the client that uses it. The stateful session bean is created by a client and will work for only that client until the client connection is dropped or the bean is explicitly removed. The stateful session bean is EJB component that implements the javax.ejb.SessionBean interface and is deployed with the declarative attribute "stateful". Stateful session beans are called "stateful" because they maintain a conversational state with the client. In other words, they have state or instance fields that can be initialized and changed by the client with each method invocation. The bean can use the conversational state as it process business methods invoked by the client.
Stateless session beans are of equal value for all instances of the bean. This means the container can assign any bean to any client, making it very scalable.
A stateless session bean is an enterprise bean that provides a stateless service to the client. Conceptually, the business methods on a stateless session bean are similar to procedural applications or static methods; there is no instance state, so all the data needed to execute the method is provided by the method arguments. The stateless session bean is an EJB component that implements the javax.ejb.SessionBean interface and is deployed with the declarative attribute "stateless". Stateless session beans are called "stateless" because they do not maintain conversational state specific to a client session. In other words, the instance fields in a stateless session bean do not maintain data relative to a client session. This makes stateless session beans very lightweight and fast, but also limits their behavior. Typically an application requires less number of stateless beans compared to stateful beans
An entity bean represents a business object in a persistent storage mechanism. An entity bean typically represents a table in a relational database and each instance represents a row in the table. Entity bean differs from session bean by: persistence, shared access, relationship and primary key.
There are two types of entity beans available. Container Managed Persistence (CMP) , Bean managed persistence (BMP
The term container-managed persistence means that the EJB container handles all database access required by the entity bean. The bean's code contains no database access (SQL) calls. As a result, the bean's code is not tied to a specific persistent storage mechanism (database). Because of this flexibility, even if you redeploy the same entity bean on different J2EE servers that use different databases, you won't need to modify or recompile the bean's code. So, your entity beans are more portable.
Bean managed persistence (BMP) occurs when the bean manages its persistence. Here the bean will handle all the database access. So the bean's code contains the necessary SQLs calls. So it is not much portable compared to CMP. Because when we are changing the database we need to rewrite the SQL for supporting the new database.
In order to generate the data access calls, the container needs information that you provide in the entity bean's abstract schema. It is a part of Deployment Descriptor. It is used to define the bean's persistent fields and relation ships.
When the bean represents a business entity, not a procedure. we should use an entity bean. Also when the bean's state must be persistent we should use an entity bean. If the bean instance terminates or if the J2EE server is shut down, the bean's state still exists in persistent storage (a database).
At any given time, only one client has access to the bean instance. The state of the bean is not persistent, existing only for a short period (perhaps a few hours). The bean implements a web service. Under all the above circumstances we can use session beans.
The bean's state represents the interaction between the bean and a specific client. The bean needs to hold information about the client across method invocations. The bean mediates between the client and the other components of the application, presenting a simplified view to the client. Under all the above circumstances we can use a stateful session bean.
The bean's state has no data for a specific client. In a single method invocation, the bean performs a generic task for all clients. For example, you might use a stateless session bean to send an email that confirms an online order. The bean fetches from a database a set of read-only data that is often used by clients. Such a bean, for example, could retrieve the table rows that represent the products that are on sale this month. Under all the above circumstance we can use a stateless session bean.
cobal interview questions ans answers
Name the divisions in a COBOL program ?
IDENTIFICATION DIVISION, ENVIRONMENT DIVISION, DATA DIVISION, PROCEDURE DIVISION.What are the different data types available in COBOL ?
Alpha-numeric (X), alphabetic (A) and numeric (9).
What does the INITIALIZE verb do ?
Alphabetic, Alphanumeric fields & alphanumeric edited items are set to SPACES. Numeric, Numeric edited items set to ZERO. FILLER , OCCURS DEPENDING ON items left untouched.
What is 77 level used for ?
Elementary level item. Cannot be subdivisions of other items (cannot be qualified), nor can they be subdivided themselves.
What is 88 level used for ?
For condition names.
What is level 66 used for ?
For RENAMES clause.
What does the IS NUMERIC clause establish ?
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 - .
How do you define a table/array in COBOL ?
ARRAYS. 05 ARRAY1 PIC X(9) OCCURS 10 TIMES. 05 ARRAY2 PIC X(6) OCCURS 20 TIMES INDEXED BY WS-INDEX.
Can the OCCURS clause be at the 01 level ?
No.
What is the difference between index and subscript ?
Subscript refers to the array occurrence while index is the displacement (in no of bytes) from the beginning of the array. An index can only be modified using PERFORM, SEARCH & SET. Need to have index for a table in order to use SEARCH, SEARCH ALL.
What is the difference between SEARCH and SEARCH ALL ?
SEARCH - is a serial search. SEARCH ALL - is a binary search & the table must be sorted ( ASCENDING/DESCENDING KEY clause to be used & data loaded in this order) before using SEARCH ALL.
What should be the sorting order for SEARCH ALL ?
It can be either ASCENDING or DESCENDING. ASCENDING is default. If you want the search to be done on an array sorted in descending order, then while defining the array, you should give DESCENDING KEY clause. (You must load the table in the specified order).
What is binary search ?
Search on a sorted array. Compare the item to be searched with the item at the center. If it matches, fine else repeat the process with the left half or the right half depending on where the item lies.
My program has an array defined to have 10 items. Due to a bug, I find that even if the program access the 11th item in this array, the program does not abend. What is wrong with it ?
Must use compiler option SSRANGE if you want array bounds checking. Default is NOSSRANGE.
How do you sort in a COBOL program Give sort file definition, sort statement syntax and meaning. ?
Syntax: SORT file-1 ON ASCENDING/DESCENDING KEY key.... USING file-2 GIVING file-3. USING can be substituted by INPUT PROCEDURE IS para-1 THRU para-2 GIVING can be substituted by OUTPUT PROCEDURE IS para-1 THRU para-2. file-1 is the sort (work) file and must be described using SD entry in FILE SECTION. file-2 is the input file for the SORT and must be described using an FD entry in FILE SECTION and SELECT clause in FILE CONTROL. file-3 is the out file from the SORT and must be described using an FD entry in FILE SECTION and SELECT clause in FILE CONTROL. file-1, file-2 & file-3 should not be opened explicitly. INPUT PROCEDURE is executed before the sort and records must be RELEASEd to the sort work file from the input procedure. OUTPUT PROCEDURE is executed after all records have been sorted. Records from the sort work file must be RETURNed one at a time to the output procedure.
How do you define a sort file in JCL that runs the COBOL program ?
Use the SORTWK01, SORTWK02,..... dd names in the step. Number of sort datasets depends on the volume of data being sorted, but a minimum of 3 is required.
What is the difference between performing a SECTION and a PARAGRAPH ?
Performing a SECTION will cause all the paragraphs that are part of the section, to be performed. Performing a PARAGRAPH will cause only that paragraph to be performed.
What is the use of EVALUATE statement ?
Evaluate is like a case statement and can be used to replace nested Ifs. The difference between EVALUATE and case is that no 'break' is required for EVALUATE i.e. control comes out of the EVALUATE as soon as one match is made.
What are the different forms of EVALUATE statement ?
EVALUATE EVALUATE SQLCODE ALSO FILE-STATUS WHEN A=B AND C=D WHEN 100 ALSO '00' imperative stmt imperative stmt WHEN (D+X)/Y = 4 WHEN -305 ALSO '32' imperative stmt imperative stmt WHEN OTHER WHEN OTHER imperative stmt imperative stmt END-EVALUATE END-EVALUATE EVALUATE SQLCODE ALSO A=B EVALUATE SQLCODE ALSO TRUE WHEN 100 ALSO TRUE WHEN 100 ALSO A=B imperative stmt imperative stmt WHEN -305 ALSO FALSE WHEN -305 ALSO (A/C=4) imperative stmt imperative stmt END-EVALUATE END-EVALUATE
How do you come out of an EVALUATE statement ?
After the execution of one of the when clauses, the control is automatically passed on to the next sentence after the EVALUATE statement. There is no need of any extra code.
In an EVALUATE statement, can I give a complex condition on a when clause ?
Yes.
What is a scope terminator ?Give examples.
Scope terminator is used to mark the end of a verb e.g. EVALUATE, END-EVALUATE; IF, END-IF.
How do you do in-line PERFORM ?
PERFORM ... ... END-PERFORM
When would you use in-line perform ?
When the body of the perform will not be used in other paragraphs. If the body of the perform is a generic type of code (used from various other places in the program), it would be better to put the code in a separate Para and use PERFORM Para name rather than in-line perform.
What is the difference between CONTINUE & NEXT SENTENCE ?
They appear to be similar, that is, the control goes to the next sentence in the paragraph. But, Next Sentence would take the control to the sentence after it finds a full stop (.). Check out by writing the following code example, one if sentence followed by 3 display statements (sorry they appear one line here because of formatting restrictions) If 1 > 0 then next sentence end if display 'line 1' display 'line 2'. display 'line 3'. *** Note- there is a dot (.) only at the end of the last 2 statements, see the effect by replacing Next Sentence with Continue ***
What does EXIT do ?
Does nothing ! If used, must be the only sentence within a paragraph.
Can I redefine an X(100) field with a field of X(200) ?
Yes. Redefines just causes both fields to start at the same location. For example: 01 WS-TOP PIC X(1) 01 WS-TOP-RED REDEFINES WS-TOP PIC X(2). If you MOVE '12' to WS-TOP-RED, DISPLAY WS-TOP will show 1 while DISPLAY WS-TOP-RED will show 12.
Can I redefine an X(200) field with a field of X(100) ?
Yes.
What do you do to resolve SOC-7 error ?
Basically you need to correcting the offending data. Many times the reason for SOC7 is an un-initialized numeric item. Examine that possibility first. Many installations provide you a dump for run time abend’s ( it can be generated also by calling some subroutines or OS services thru assembly language). These dumps provide the offset of the last instruction at which the abend occurred. Examine the compilation output XREF listing to get the verb and the line number of the source code at this offset. Then you can look at the source code to find the bug. To get capture the runtime dumps, you will have to define some datasets (SYSABOUT etc ) in the JCL. If none of these are helpful, use judgement and DISPLAY to localize the source of error. Some installation might have batch program debugging tools. Use them.
How is sign stored in Packed Decimal fields and Zoned Decimal fields ?
Packed Decimal fields: Sign is stored as a hex value in the last nibble (4 bits ) of the storage. Zoned Decimal fields: As a default, sign is over punched with the numeric value stored in the last bite.
How is sign stored in a comp-3 field ?
It is stored in the last nibble. For example if your number is +100, it stores hex 0C in the last byte, hex 1C if your number is 101, hex 2C if your number is 102, hex 1D if the number is -101, hex 2D if the number is -102 etc...
How is sign stored in a COMP field ?
In the most significant bit. Bit is ON if -ve, OFF if +ve.
What is the difference between COMP & COMP-3 ?
COMP is a binary storage format while COMP-3 is packed decimal format.
What is COMP-1 ? COMP-2 ?
COMP-1 - Single precision floating point. Uses 4 bytes. COMP-2 - Double precision floating point. Uses 8 bytes.
How do you define a variable of COMP-1 ? COMP-2 ?
No picture clause to be given. Example 01 WS-VAR USAGE COMP-1.
How many bytes does a S9(7) COMP-3 field occupy ?
Will take 4 bytes. Sign is stored as hex value in the last nibble. General formula is INT((n/2) + 1)), where n=7 in this example.
How many bytes does a S9(7) SIGN TRAILING SEPARATE field occupy ?
Will occupy 8 bytes (one extra byte for sign).
How many bytes will a S9(8) COMP field occupy ?
4 bytes.
What is the maximum value that can be stored in S9(8) COMP ?
99999999
What is COMP SYNC ?
Causes the item to be aligned on natural boundaries. Can be SYNCHRONIZED LEFT or RIGHT. For binary data items, the address resolution is faster if they are located at word boundaries in the memory. For example, on main frame the memory word size is 4 bytes. This means that each word will start from an address divisible by 4. If my first variable is x(3) and next one is s9(4) comp, then if you do not specify the SYNC clause, S9(4) COMP will start from byte 3 ( assuming that it starts from 0 ). If you specify SYNC, then the binary data item will start from address 4. You might see some wastage of memory, but the access to this computational field is faster.
What is the maximum size of a 01 level item in COBOL I ? in COBOL II ?
In COBOL II: 16777215
How do you reference the following file formats from COBOL programs: ?
Fixed Block File - Use ORGANISATION IS SEQUENTIAL. Use RECORDING MODE IS F, BLOCK CONTAINS 0 . Fixed Unblocked - Use ORGANISATION IS SEQUENTIAL. Use RECORDING MODE IS F, do not use BLOCK CONTAINS Variable Block File - Use ORGANISATION IS SEQUENTIAL. Use RECORDING MODE IS V, BLOCK CONTAINS 0. Do not code the 4 bytes for record length in FD ie JCL rec length will be max rec length in pgm + 4 Variable Unblocked - Use ORGANISATION IS SEQUENTIAL. Use RECORDING MODE IS V, do not use BLOCK CONTAINS. Do not code 4 bytes for record length in FD ie JCL rec length will be max rec length in pgm + 4. ESDS VSAM file - Use ORGANISATION IS SEQUENTIAL. KSDS VSAM file - Use ORGANISATION IS INDEXED, RECORD KEY IS, ALTERNATE RECORD KEY IS RRDS File - Use ORGANISATION IS RELATIVE, RELATIVE KEY IS Printer File - Use ORGANISATION IS SEQUENTIAL. Use RECORDING MODE IS F, BLOCK CONTAINS 0. (Use RECFM=FBA in JCL DCB).
What are different file OPEN modes available in COBOL ?
Open for INPUT, OUTPUT, I-O, EXTEND.
What is the mode in which you will OPEN a file for writing ?
OUTPUT, EXTEND
In the JCL, how do you define the files referred to in a subroutine ?
Supply the DD cards just as you would for files referred to in the main program.
Can you REWRITE a record in an ESDS file ? Can you DELETE a record from it ?
Can rewrite (record length must be same), but not delete.
What is file status 92 ?
Logic error. e.g., a file is opened for input and an attempt is made to write to it.
What is file status 39 ?
Mismatch in LRECL or BLOCKSIZE or RECFM between your COBOL pgm & the JCL (or the dataset label). You will get file status 39 on an OPEN.
What is Static and Dynamic linking ?
In static linking, the called subroutine is link-edited into the calling program , while in dynamic linking, the subroutine & the main program will exist as separate load modules. You choose static/dynamic linking by choosing either the DYNAM or NODYNAM link edit option. (Even if you choose NODYNAM, a CALL identifier (as opposed to a CALL literal), will translate to a DYNAMIC call).A statically called subroutine will not be in its initial state the next time it is called unless you explicitly use INITIAL or you do a CANCEL. A dynamically called routine will always be in its initial state.
What is AMODE(24), AMODE(31), RMODE(24) and RMODE(ANY) ?
(applicable to only MVS/ESA Enterprise Server). These are compile/link edit options. Basically AMODE stands for Addressing mode and RMODE for Residency mode. AMODE(24) - 24 bit addressing; AMODE(31) - 31 bit addressing AMODE(ANY) - Either 24 bit or 31 bit addressing depending on RMODE. RMODE(24) - Resides in virtual storage below 16 Meg line. Use this for 31 bit programs that call 24 bit programs. (OS/VS Cobol pgms use 24 bit addresses only). RMODE(ANY) - Can reside above or below 16 Meg line.
What compiler option would you use for dynamic linking ?
DYNAM.
What is SSRANGE, NOSSRANGE ?
These are compiler options with respect to subscript out of range checking. NOSSRANGE is the default and if chosen, no run time error will be flagged if your index or subscript goes out of the permissible range.
How do you set a return code to the JCL from a COBOL program ?
Move a value to RETURN-CODE register. RETURN-CODE should not be declared in your program.
How can you submit a job from COBOL programs ?
Write JCL cards to a dataset with //xxxxxxx SYSOUT= (A,INTRDR) where 'A' is output class, and dataset should be opened for output in the program. Define a 80 byte record layout for the file.
What are the differences between OS VS COBOL and VS COBOL II ?
OS/VS Cobol pgms can only run in 24 bit addressing mode, VS Cobol II pgms can run either in 24 bit or 31 bit addressing modes. I. Report writer is supported only in OS/VS Cobol. II. USAGE IS POINTER is supported only in VS COBOL II. III. Reference modification e.g.: WS-VAR(1:2) is supported only in VS COBOL II. IV. EVALUATE is supported only in VS COBOL II. V. Scope terminators are supported only in VS COBOL II. VI. OS/VS Cobol follows ANSI 74 stds while VS COBOL II follows ANSI 85 stds. VII. Under CICS Calls between VS COBOL II programs are supported.
What are the steps you go through while creating a COBOL program executable ?
DB2 precompiler (if embedded SQL used), CICS translator (if CICS pgm), Cobol compiler, Link editor. If DB2 program, create plan by binding the DBRMs.
Can you call an OS VS COBOL pgm from a VS COBOL II pgm ?
In non-CICS environment, it is possible. In CICS, this is not possible.
What are the differences between COBOL and COBOL II ?
There are at least five differences: COBOL II supports structured programming by using in line Performs and explicit scope terminators, It introduces new features (EVALUATE, SET. TO TRUE, CALL. BY CONTEXT, etc) It permits programs to be loaded and addressed above the 16-megabyte line It does not support many old features (READY TRACE, REPORT-WRITER, ISAM, Etc.), and It offers enhanced CICS support.
What is an explicit scope terminator ?
A scope terminator brackets its preceding verb, e.g. IF .. END-IF, so that all statements between the verb and its scope terminator are grouped together. Other common COBOL II verbs are READ, PERFORM, EVALUATE, SEARCH and STRING.
What is an in line PERFORM ? When would you use it ? Anything else to say about it ?
The PERFORM and END-PERFORM statements bracket all COBOL II statements between them. The COBOL equivalent is to PERFORM or PERFORM THRU a paragraph. In line PERFORMs work as long as there are no internal GO TOs, not even to an exit. The in line PERFORM for readability should not exceed a page length - often it will reference other PERFORM paragraphs.
What is the difference between NEXT SENTENCE and CONTINUE ?
NEXT SENTENCE gives control to the verb following the next period. CONTINUE gives control to the next verb after the explicit scope terminator. (This is not one of COBOL II's finer implementations). It's safest to use CONTINUE rather than NEXT SENTENCE in COBOL II.
What COBOL construct is the COBOL II EVALUATE meant to replace ?
EVALUATE can be used in place of the nested IF THEN ELSE statements.
What is the significance of 'above the line' and 'below the line' ?
Before IBM introduced MVS/XA architecture in the 1980's a program's virtual storage was limited to 16 megs. Programs compiled with a 24 bit mode can only address 16 Mb of space, as though they were kept under an imaginary storage line. With COBOL II a program compiled with a 31 bit mode can be 'above the 16 Mb line. (This 'below the line', 'above the line' imagery confuses most mainframe programmers, who tend to be a literal minded group.)
What was removed from COBOL in the COBOL II implementation ?
Partial list: REMARKS, NOMINAL KEY, PAGE-COUNTER, CURRENT-DAY, TIME-OF-DAY, STATE, FLOW, COUNT, EXAMINE, EXHIBIT, READY TRACE and RESET TRACE.
Explain call by context by comparing it to other calls. ?
The parameters passed in a call by context are protected from modification by the called program. In a normal call they are able to be modified.
What is the linkage section ?
The linkage section is part of a called program that 'links' or maps to data items in the calling program's working storage. It is the part of the called program where these share items are defined.
What is the difference between a subscript and an index in a table definition ?
A subscript is a working storage data definition item, typically a PIC (999) where a value must be moved to the subscript and then incremented or decrements by ADD TO and SUBTRACT FROM statements. An index is a register item that exists outside the program's working storage. You SET an index to a value and SET it UP BY value and DOWN BY value.
If you were passing a table via linkage, which is preferable - a subscript or an index ?
Wake up - you haven't been paying attention! It's not possible to pass an index via linkage. The index is not part of the calling programs working storage. Those of us who've made this mistake, appreciate the lesson more than others.
Explain the difference between an internal and an external sort, the pros and cons, internal sort syntax etc. ?
An external sort is not COBOL; it is performed through JCL and PGM=SORT. It is understandable without any code reference. An internal sort can use two different syntax’s: 1.) USING, GIVING sorts are comparable to external sorts with no extra file processing; 2) INPUT PROCEDURE, OUTPUT PROCEDURE sorts allow for data manipulation before and/or after the sort.
What is the difference between comp and comp-3 usage ? Explain other COBOL usage’s. ?
Comp is a binary usage, while comp-3 indicates packed decimal. The other common usage’s are binary and display. Display is the default.
When is a scope terminator mandatory ?
Scope terminators are mandatory for in-line PERFORMS and EVALUATE statements. For readability, it's recommended coding practice to always make scope terminators explicit.
In a COBOL II PERFORM statement, when is the conditional tested, before or after the perform execution ?
In COBOL II the optional clause WITH TEST BEFORE or WITH TEST AFTER can be added to all perform statements. By default the test is performed before the perform.
In an EVALUTE statement is the order of the WHEN clauses significant ?
Absolutely. Evaluation of the WHEN clauses proceeds from top to bottom and their sequence can determine results.
What is the default value(s) for an INITIALIZE and what keyword allows for an override of the default. ?
INITIALIZE moves spaces to alphabetic fields and zeros to alphanumeric fields. The REPLACING option can be used to override these defaults.
What is SET TO TRUE all about, anyway ?
In COBOL II the 88 levels can be set rather than moving their associated values to the related data item. (Web note: This change is not one of COBOL II's better specifications.)
What is LENGTH in COBOL II ?
LENGTH acts like a special register to tell the length of a group or elementary item.
What is the difference between a binary search and a sequential search ? What are the pertinent COBOL commands ?
In a binary search the table element key values must be in ascending or descending sequence. The table is 'halved' to search for equal to, greater than or less than conditions until the element is found. In a sequential search the table is searched from top to bottom, so (ironically) the elements do not have to be in a specific sequence. The binary search is much faster for larger tables, while sequential works well with smaller ones. SEARCH ALL is used for binary searches; SEARCH for sequential.
What is the point of the REPLACING option of a copy statement ?
REPLACING allows for the same copy to be used more than once in the same code by changing the replace value.
What will happen if you code GO BACK instead of STOP RUN in a stand alone COBOL program i.e. aprogram which is not calling any other program. ?
The program will go in an infinite loop.
How can I tell if a module is being called DYNAMICALLY or STATICALLY ?
The ONLY way is to look at the output of the linkage editor (IEWL)or the load module itself. If the module is being called DYNAMICALLY then it will not exist in the main module, if it is being called STATICALLY then it will be seen in the load module. Calling a working storage variable, containing a program name, does not make a DYNAMIC call. This type of calling is known as IMPLICITE calling as the name of the module is implied by the contents of the working storage variable. Calling a program name literal (CALL
What is the difference between a DYNAMIC and STATIC call in COBOL. ?
To correct an earlier answer: All called modules cannot run standalone if they require program variables passed to them via the LINKAGE section. DYNAMICally called modules are those that are not bound with the calling program at link edit time (IEWL for IBM) and so are loaded from the program library (joblib or steplib) associated with the job. For DYNAMIC calling of a module the DYNAM compiler option must be chosen, else the linkage editor will not generate an executable as it will expect u address resolution of all called modules. A STATICally called module is one that is bound with the calling module at link edit, and therefore becomes part of the executable load module.
How may divisions are there in JCL-COBOL ?
SIX
What is the purpose of Identification Division ?
Documentation.
What is the difference between PIC 9.99 and 9v99 ?
PIC 9.99 is a FOUR-POSITION field that actually contains a decimal point where as PIC 9v99 is THREE- POSITION numeric field with implied or assumed decimal position.
what is Pic 9v99 Indicates ?
PICTURE 9v99 is a three position Numeric field with an implied or assumed decimal point after the first position; the v means an implied decimal point.
What guidelines should be followed to write a structured Cobol prg'm ?
1) use 'evaluate' stmt for constructing cases. 2) use scope terminators for nesting. 3) use in line perform stmt for writing 'do ' constructions. 4) use test before and test after in the perform stmt for writing do-while constructions.
Read the following code. 01 ws-n pic 9(2) value zero. a-para move 5 to ws-n. perform b-para ws-n times. b-para. move 10 to ws-n. how many times will b-para be executed ?
5 times only. it will not take the value 10 that is initialized in the loop.
What is the difference between SEARCH and SEARCH ALL ? What is more efficient ?
SEARCH is a sequential search from the beginning of the table. SEARCH ALL is a binary search, continually dividing the table in two halves until a match is found. SEARCH ALL is more efficient for tables larger than 70 items.
What are some examples of command terminators ?
END-IF, END-EVALUATE
What care has to be taken to force program to execute above 16 Meg line ?
Make sure that link option is AMODE=31 and RMODE=ANY. Compile option should never have SIZE(MAX). BUFSIZE can be 2K, efficient enough.
How do you submit JCL via a Cobol program ?
Use a file //dd1 DD sysout=(*, intrdr)write your JCL to this file. Pl some on try this out.
How to execute a set of JCL statements from a COBOL program?
Using EXEC CICS SPOOL WRITE(var-name) END-EXEC command. var-name is a COBOL host structure containing JCL statements.
Give some advantages of REDEFINES clause. ?
1. You can REDEFINE a Variable from one PICTURE class to another PICTURE class by using the same memory location. 2. By REDEFINES we can INITIALISE the variable in WORKING-STORAGE Section itself. 3. We can REDEFINE a Single Variable into so many sub variables. (This facility is very useful in solving Y2000 Problem.)
What is the difference between static call & Dynamic call?
In the case of Static call, the called program is a stand-alone program, it is an executable program. During run time we can call it in our called program. As about Dynamic call, the called program is not an executable program it can executed through the called program
What do you feel makes a good program ?
A program that follows a top down approach. It is also one that other programmers or users can follow logically and is easy to read and understand.
How do you code Cobol to access a parameter that has been defined in JCL ? And do you code the PARM parameter on the EXEC line in JCL ?
1) using JCL with sysin. //sysin dd *here u code the parameters(value) to pass in to cobol program /* and in program you use accept variable name(one accept will read one row)/.another way. 2) in jcl using parm statement ex: in exec statement parm='john','david' in cobol pgm u have to code linkage section in that for first value you code length variable and variable name say, abc pic x(4).it will take john inside to read next value u have to code another variable in the same way above mentioned.
Why do we code S9(4) comp. Inspite of knowing comp-3 will occupy less space. ?
Here s9(4)comp is small integer ,so two words equal to 1 byte so totally it will occupy 2 bytes(4 words).here in s9(4) comp-3 as one word is equal to 1/2 byte.4 words equal to 2 bytes and sign will occupy 1/2 byte so totally it will occupy 3 bytes.
The maximum number of dimensions that an array can have in COBOL-85 is ----------- ?
SEVEN in COBOL - 85 and THREE in COBOL - 84
How do you declare a host variable (in COBOL) for an attribute named Emp-Name of type VARCHAR(25) ?
01 EMP-GRP. 49 E-LEN PIC S9(4) COMP. 49 E-NAME PIC X(25).
What is Comm ?
COMM - HALF WORD BINARY
Differentiate COBOL and COBOL-II. (Most of our programs are written in COBOLII, so, it is good to know, how, this is different from COBOL) ?
The following features are available with VS COBOL II: 1. MVS/XA and MVS/ESA support The compiler and the object programs it produces can be run in either 24- or 31-bit addressing mode. 2. VM/XA and VM/ESA support The compiler and the object programs it produces can be run in either 24- or 31-bit addressing mode. 3. VSE/ESA support The compiler and the object programs it produces can be run under VSE/ESA.
What is PERFORM ?What is VARYING ?
(More details about these clauses) The PERFORM statement is a PROCEDURE DIVISION statement which transfers control to one or more specified procedures and controls as specified the number of times the procedures are executed. After execution of the specified procedures is completed (i.e., for the appropriate number of times or until some specified condition is met), control is transferred to the next executable statement following the PERFORM statement. There are 5 types of PERFORM statements: a) Basic PERFORM b) PERFORM TIMES c) PERFORM UNTIL d) PERFORM VARYING e) IN-LINE PERFORM
How many sections are there in data division ?
SIX SECTIONS 1.FILE SECTION 2.WORKING-STORAGE SECTION 3. LOCAL-STORAGE SECTION 4.SCREEN SECTION 5.REPORT SECTION 6. LINKAGE SECTION
What is Redefines clause ?
Redefines clause is used to allow the same storage allocation to be referenced by different data names .
How many bytes does a s9(4)comp-3 field occupy ?
3Bytes (formula : n/2 + 1))
What is the different between index and subscript ?
Subscript refers to the array of occurrence , where as Index represents an occurrence of a table element. An index can only modified using perform, search & set. Need to have an index for a table in order to use SEARCH and SEARCH All.
What is the difference between Structured COBOL Programming and Object Oriented COBOL programming ?
Structured programming is a Logical way of programming, you divide the functionalities into modules and code logically. OOP is a Natural way of programming; you identify the objects first, and then write functions, procedures around the objects. Sorry, this may not be an adequate answer, but they are two different programming paradigms, which is difficult to put in a sentence or two.
What divisions, sections and paragraphs are mandatory for a COBOL program ?
IDENTIFICATION DIVISION and PROGRAM-ID paragraph are mandatory for a compilation error free COBOL program.
Can JUSTIFIED be used for all the data types ?
No, it can be used only with alphabetic and alphanumeric data types.
What happens when we move a comp-3 field to an edited (say z (9). ZZ-) ?
the editing characters r to be used with data items with usage clause as display which is the default. When u tries displaying a data item with usage as computational it does not give the desired display format because the data item is stored as packed decimal. So if u want this particular data item to be edited u have to move it into a data item whose usage is display and then have that particular data item edited in the format desired.
What will happen if you code GO BACK instead of STOP RUN in a stand-alone COBOL program i.e. a program which is not calling any other program ?
Both give the same results when a program is not calling any other program. GO BACK will give the control to the system even though it is a single program.
what is the difference between external and global variables ?
Global variables are accessible only to the batch program whereas external variables can be referenced from any batch program residing in the same system library.
You are writing report program with 4 levels of totals: city, state, region and country. The codes being used can be the same over the different levels, meaning a city code of 01 can be in any number of states, and the same applies to state and region code so how do you do your checking for breaks and how do you do add to each level ?
Always compare on the highest-level first, because if you have a break at a highest level, each level beneath it must also break. Add to the lowest level for each record but add to the higher level only on a break.
What is difference between COBOL and VS COBOL II ?
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.
Why occurs can not be used in 01 level ?
Because, Occurs clause is there to repeat fields with same format, not the records.
What is report-item ?
A Report-Item Is A Field To Be Printed That Contains Edit Symbols
Difference between next and continue clause?
The difference between the next and continue verb is that in the continue verb it is used for a situation where there in no EOF condition that is the records are to be accessed again and again in an file, whereas in the next verb the indexed file is accessed sequentially, read next record command is used.
What is the Importance of GLOBAL clause According to new standards of COBOL?
When any data name, file-name, Record-name, condition name or Index defined in an Including Program can be referenced by a directly or indirectly in an included program, Provided the said name has been declared to be a global name by GLOBAL Format of Global Clause is01 data-1 pic 9(5) IS GLOBAL.
What is the Purpose of POINTER Phrase in STRING command?
The Purpose of POINTER phrase is to specify the leftmost position within receiving field where the first transferred character will be stored
How do we get current date from system with century ?
By using Intrinsic function, FUNCTION CURRENT-DATE
What is the maximum length of a field you can define using COMP-3 ?
10 Bytes (S9(18) COMP-3).
Why do we code s9 (4) comp ?In spite of knowing comp-3 will occupy less space ?
Here s9(4)comp is small integer, so two words equal to 1 byte so totally it will occupy 2 bytes(4 words).here in s9(4) comp-3 as one word is equal to 1/2 byte.4 words equal to 2 bytes and sign will occupy 1/2 byte so totally it will occupy 3 bytes.
What is the LINKAGE SECTION used for ?
The linkage section is used to pass data from one program to another program or to pass data from a PROC to a program.
Describe the difference between subscripting and indexing ?
Indexing uses binary displacement. Subscripts use the value of the occurrence.