Class 12 IP Viva Questions with answers

Class 12 IP Viva Questions with Answers is the best collection of Questions and their best short answers. Just read this list of Ip viva questions before taking your final class 12 IP practical examination as your external examiner is going to ask these types of viva questions.


Q1. Difference between setText()  and getText()?

Set text () method stores or changes text in a text based GUI component. For eg. Text field, Text area, get text() method returns the text currently stored in a text based GUI component. For eg. Label, Check Box, etc.

Q2. Difference between combobox and listbox?

The list a user may directly select from list whereas in combo box user can edit if he/she wishes. List have text field where user can edit the selected item where as combo box is a cross between a text field and a list.

Q3. What is entry control and exit control loop?

The loop condition is tested before entering in to the loop is called entry control loop like for and while loop. In exit control loop it first execute loop body and than evaluate the continuation condition like while loop.

Q4. Give the introduction about your project?

Q5. Through which property of radio button can we select  one radio button at a time?

Through button group property of radio button we can select one radio button at a time.

Q6. What is the use of import in java?

Q7. What is as String Class?

String class is used to accept textual data.

Q8. What are data types?

Q9 What is the use of parse method  in java?

It is used to convert from one data type to other. Eg Integer .parseInt converts from string to integer.

Eg: int a=Integer.parseInt(jTextFile1.getText());

Q10.  Name one native class of Java.

     jTextField, jRadioButton etc.

Q11. How can we convert a string into upper case in JAVA?

     Using toupper() function of string class. Eg str1.toupper();

Q12. What are math functions and string functions explain?

Q13. What is backend and front end?

Front End :- It is the user interface that the user sees and which is resp outside for interacting with the user. The interface allows used to uses commands to the system.

Back End:- It is the Part of Application that does the real processing or get it done from the server.

Q14. What is connectivity?

Q15. What is the use of following methods :    forName(); getConnection();, createStatement(), executeQuery, executeUpdate(),getModel(), getRowCount();removeRow().

Q16. What is HTML?

HTML stands for Hyper Text Markup language. It is a markup language used to create HTML documents. An HTML defines a Web Page.

Q17  What is the difference between HTML and XML?

HTML:- New Tags cannot be created using HTML tags, HTML tags can be empty tags

XML :- New tags can be created using XML tags., XML tags cannot be empty tags.

Q18. What is primary key?

Primary key is a combination of columns that uniquely identifies a row in a relational table.

Q19. What is candidate key?

All possible combination of columns that can possibly serve as the primary key is called candidate key.

Q20. What is foreign key?

A combination of columns where values are derived from primary key of some other table is called the foreign key of the table in which it is contained

Q21. What is alternate key?

A candidate key that is not serving as a primary key is called alternate key.

Q22. How can we convert a string into upper case in mysql and java?

Q23. How can we convert a string into lower case in mysql and java?

Q24. What is Mysql?

Mysql is an open source RDBMS that relies on SQL for processing the data in the database.

Q25. What is RDBMS ?

Relational Database Management System facilitates access, security and integrity of data & eliminates data redundancy. Eg. Mysql, Oracle, Microsoft Sql Server etc.

Q26. How many types of functions are there in MYSQL?

There are three basic categories : Numeric, String/character and Date and Time functions in MySQL.

Q27. What is a Tuple, Relation, Attribute?

Tuple: the rows of the table are called tuples.

Relation : A relation is two dimensional table.

Attribute: The column of tables are called attribute.

Q28. What is degree and cardinality?

Degree – Number of attributes (columns) in a relation is called degree Cardinality – Number of types (rows) in a relation is called cardinality.  

Q29. What is the significance of Having Clause?

Having clause is used with group by. It is used to select particular rows according to a condition.

Q28. What is the significance of select statement?

      The Select statement is used to query the table depending on a condition or     set of conditions. It is also used to manipulate the records.

Q29. What are DDL Commands Explain with examples?

Data Definition Language (DDL) commands allow us to perform tasks related to data definition. Eg. Creating, altering, and dropping granting & revoking privileges & roles.

Q30. What are DML Commands Explain with examples?

Data Manipulation Language (DML) commands allow us to perform data manipulation. Eg. Retrieval, Insertion, Deletion and Modification of data stored in a database.

Q31. What are TCL Commands Explain with examples?

Transmission Control Language (TCL) commands allows us to manage and control the transaction. Eg. Commit, Rollback, Savepoint etc.

Q32. What is the use of Drop Command?

Drop command is used to delete tables. Eg. Drop Table Orders, Delete commands is used to delete, rows of a table.

Q33. What is the use of DESCRIBE command?

Q34. What are Logical Operators  explain?

Q35. What is the use of LIKE , Between and  IN Operators ?

Q36. What is the difference between Update and Alter table?

Q37. What is the difference between Where and Having?

Q38 What are constraints?

They are used to enforce rules at table level wherever row is inserted, updated or deleted from the table.

  1. What is the difference between DROP and DELETE?
  1. What do you understand by Check Constraint?
  1. What do you understand by primary key constraint?

This constraint enforces uniqueness of the column. Only one primary key per table is allowed.

  1. What do you understand by Default constraint?
  1. What do you understand by Not null constraint?

This constraints ensures that the null values are not permitted or a specified column. This constraint can be defined at the column level not at the table level.

  1. What do you understand by unique constraint?
  1. What is significance of COUNT?

It is used to count the numbers of values in a gives column or no. of rows in a table. Eg. Select count (Roll No.) from students.

  1. Explain joins in  Mysql?
  1. What is Union operation?

Union is an operation of combining the output of two select statements.

  1. What is the difference between Where and Having?
  1. What is difference between order by and group by clause?
  1. What is difference between rollback and commit?
  1. What is SavePoint?

Save point command sreates a point in transaction upto which all changes have been saved properly and permanently.

  1. What is conditional operator?
  1. What are unary, binary and ternary operator?
  1. What is swing?
  1. Swing include a rich set of graphical component for building GUI
  1. What are top level containers?
  1. Top level container are the container which hold other container in it For eg. Frame.
  1. What is difference between text area and text field?

Text area is a component that allow us to accept multiline input from the user or display multiline information whereas text field allows editing/displaying of a single line of text.

  1. What are the type of inheritance supported by netbeans?
  1. What do you mean by save point?
  1. The savepoint statement defines a marker in a transaction. These marker are useful in roll backing a transaction.
  1. How can we delete a table in MYSQL?

We can delete a table in mysql using drop command.

  1. How can we delete a record in MYSQL?

We can delete a record in mysql using delete command.

  1. How can we add a record and add a column in a table ?

We can add a record by using insert command and we can add a column through table.

  1. What are the parts of a method?

Method can be divided into two categories : getters & setters Getters : they extract (input) information from the object -> Program Setters : They set some property of the object so that the change object’s appearance.

  1. What is difference between ‘=’ and ‘==’?

=  is used for assignment value

= = is used for equality

  1. What is difference between ‘a’ and “a”?

‘a’ is a char type whereas

“a” is a string type

  1. What is difference between ++a and a++?

++a in this value is incremented first then the new value is stored  back to the variable. A++ in this expression the current value is assigned to a variable and then incremented by 1.

  1. What is difference between –a and a–?
  1. Difference between while and do while?

While is a entry control loop whereas do while is exit control loop.

  1. What is Networking?

Networking is a collection of interconnected computers and other devices which are able to communicate with each other  and share hardware and software resources.

  1. What is tree Topology how does it work?

Tree topology is a communication of bus and star topology.

  1. What is Bus Topology how does it work?

In bus topology all the nodes are connected to a main cable called backbone if any node has to send information to another node it sends signal to backbone. The signal travel entire length and received by the intended node and information is absored by terminator to remove it.

  1. What is Star Topology how does it work?

In star topology each node is directly connected to hub if any node has to send some information to any other node it sends the signal to hub. The signal is broadcast to all node but it is accepted by intended node.

  1. What is guided media and unguided media?

Guided media include cables whereas unguided media include waves through air.

  1. What is Gateway?

A gateway is a device which is used to connect different types of networks and perform the necessary translation so that the connected networks can communicate properly.

  1. What are Network Protocols?

A networks protocol is a set of rules for communication among networked devices. Protocol generally includes rules of how and when a device can send or receive the data.

  1. What is HTTP?

HTTP is used to transfer all files and other data from one computer to another on world wide web. HTTP stands for Hyper Text Transfer Protocol.

  1. What is TCP/IP?

Every machine on a TCP?IP network has a unique identifying number called an IP address:

  1. What is PPP?
  1. What are the different types of Network?
  1. What is PAN, LAN,MAN,WAN?

PAN :- Personal Area network, LAN :- Local Area Network, Man:- Metropolitan Area Network, WAN :- Wide Area Network.

  1. What is Transmission Media?
  1. What is the difference between Twisted Pair Cable and Unshilded Twisted Pair?
  1. What are Co-axial cables ?

This type of cable consists of a solid wire core surrounded by our or more foil, each separated by some plastic insulator.

  1. What are Optical Fiber Cables?
  1. What are Radio Waves?
  1. What are Micro Waves?
  1. What are Radio Waves?
  1. What are Infrared Waves?
  1. What is Blutooth?
  1. What is Satellite Link?
  1. What is Repeater and Switch? Give Difference.

100.A repeater is a device that amplifies a signal being transited on a network. It is used in long _______

101.What is HUB?

A HUB is a hardware device used to connect several computers together. Hub can be either Active & Passive hubs.

102.What is NIC?

103.What do you understand by MAC address?

The hardware address of the networks card is caused MAC address, which becomes computers unique hardware number on a network.

104.What is the difference between IP Address and Mac Address?

MAC address refers to the physical address assigned by NIC manufacturer. IP address is a mechanism that obtains IP address using a URL of a website.

105.What is Domain Name?

106.What are Generic Domain Name?

107.What are Country Specific Domain Names?

108.What do you understand by Network Secutity?

109.What are Denial of service attacks?

DOS attacks are those attacks that present the legitimate user of the system from accessing on using the resources, information of the system.

110.What is Snooping?

Snooping refers to the unauthorized access of someone else data, Email, computer activity or data communication.

111.What is Eavesdropping?

Eavesdropping is the act of secretly listening someone else private communication/Information.

112.What is Firewall?

The system designed to prevent unauthorized access to or from a private network is caused firewall.

113.Describe the parts of an object?

The Parts of an object are :-

  1. Properties, methods and events can be used to control the objects appearance and behavior.

Properties of an object are used to specify its appearance on the form. Eg. Changing the front of text field.

Methods are used to perform some action on the object. Eg. To display something in a textfield, you can use it set Text () method.

Events are actions / performed on controls. Eg. Mouse click etc.

114.Which method can be used to make the object or components visible or invisible?

Set Visible

Name any two Object Oriented Programming languages?

Ans. C++ and Java

Q2. Why is java called a platform independent language?

Ans Java program can be easily moved from one computer system to another, anywhere anytime.

Changes and upgrade in operating system, processors and system resources will not force any change in the Java program. Hence it is called a platform independent language.

Q3. Elaborate the java Compilation process.

Ans. The source program is first converted into a byte code using a java compiler. This byte code is machine independent i.e. same for all the machines. Later the byte code is executed on the machine using an interpreter.

Q4. Why do we write a comment in a program? What are the two ways of writing comment in a java Program?

Ans. Comments are added to a program for the following purposes:-

  1. Make the more readable and understandable
  1. For future references we can add comments in a Java program in the following ways:
  1. i) Adding // before the line which is to be commented. This can be used only for single

line comments.

  1. ii) using a pair of /* and */ for multi-line comments.

Q5. What is a syntax error in context of a program? Give an example.

Ans. Error in the way of writing a statement in a program, results in a syntax error.

For e.g.

for ( i=0, i<=100. i++), will result in a syntax because the program has written

comma instead of a semi colon in the for loop.

Q6. What is RAD programming? Why is program development in java using Netbeans IDE is


Ans. RAD stands for Rapid Application Development. A programming style which aims at building programs fastly through the use of tools and wizards is called RAD.

Program development using Netbeans IDE is RAD as it

  • provides GUI
  • Provides online help and suggestions during typing of the program

(using ctrl+ Spacebar key)

  • Error alerts while typing of the program.

Q7. What is IDE? Name two IDE for Programming in java.

Ans. A programming environment, where all the tools required for programming are available under one roof is called IDE. Two IDE for Java are Netbeans and BlueJ

Q8. Name any two type of Tokens available in Java.

Ans. Keyword, Identifier, Literal, Punctuators ad Operators.

Q9. What are primitive data types? Name the various primitive data type available in Java.

Ans. Data types that are directly available with java are called primitive data type.

Various primitive data types available in java are byte, short, int, long, float,

double, char and boolean.

Q10. What are Reference data types?

Ans. Data types created by the programmer using the primitive data type are called

reference data type e.g. Classes, interfaces etc.

Q11. What is type casting?

Ans. Converting a value form one type to another is called type casting.

For e.g. int a = 5 . here ‘a’ is a integer, which can be cased to float as follows

float b = (float) a;

Q12. Name and explain the usage of any two data types used in Java to store numbers with decimals.

Ans. Two data types available in java for storing numbers with decimals are

  1. float: for single precision floating point values for e.g. float num = 10.0F
  1. double: for double precision floating point value. This is the default data type

for decimal numbers. for e.g. double num = 10.0

Q13. What are Keywords? Give two examples of keywords available in Java.

Ans. Keywords are words that have a specific predefined meaning in Java. They cannot be used as variable names. Eg. void, private, if, while etc.

Q14. Name and explain the usage of any one relational and one logical operator in Java.

Ans. One relational operator in java is ==. This operator results in true if both its operands are equal otherwise false. One logical operator in java is &&. This operator is used to combine two logical values. The result of the && will be true if and only if both its operands are true otherwise false.

Q15. What is the difference between = and == operator in java?

Ans. Represent an assignment operator. It sets the value of the variable on its left side with the result of expression on its right side. == represent a conditional equal to operator. It checks for the equality of both its operands. If both the operands are equal, condition evaluates to true otherwise to false.

Q16. Name the two type of selection statement available in Java.

Ans. Two selection statement available in java are ‘if’ and ‘Switch’

Q17. Write the purpose of Switch Statement with the help of an example. Which Java Statement can be used in place of switch statement? In the switch statement, what happens if every case fails and there is no default option?

Ans. A Switch statement is used execute a statement from a group of statement based on the result of a expression. The expression must result in either of byte, short, integer or character. An ‘if statement’ can be used in place of switch statement. In a switch statement if none of the statement satisfies and even there is no default case then nothing would happen. This would not result in any sort of error.

Q18. What is the purpose of ‘break’ statement in java?

Ans. Break is used to terminate the current switch statement or the loop.

Q19. What is the purpose of ‘continue’ statement in java?

Ans. Continue statement skips the remaining part of the current loop and begins the next iteration of the loop.

Q20 Find the output of the following code snippet written in java

public static void main(String []args)


long a=78345,s1=0,s2=0,r;




if (r%4==0)

s1+= r;





System.out.println(“S1 =”+ s1);

System.out.println(“S2 =”+ s2);


Ans. Output:

s1= 12

s2= 15

Q21. Correct the errors in the following program segment written in JAVA. You are just required to write the corrected code, underlying the corrections made.

public Static Void Main (String [] args)


Integer Nos = 100;

while (Nos => 45)


If (Nos % 5 = 0);



Nos + = 20;



Ans: Corrected Code

public static void main (String [] args)


int Nos = 100;

while (Nos >= 45)


if (Nos % 5 == 0)_



Nos + = 20;



Unsolved Questions

  1. What will be output of the following code:

byte b;

double d= 417.35;

b= (byte) d;


  1. Given the value of a variable, write a statement, without using if construct, which will produce the absolute value of a variable.
  1. What is wrong with the following code fragment?

Switch (x)


case 1:

n1= 10;

n2= 20;

case 2:



n4= 40;


  1. What will be the output of the following program code?

int m = 100;

int n = 300;

while(++m < –n);

System.out.println(m+” “+ n);

  1. What does the following fragment display

String s = “Six:” + 3+ 3;


  1. What is the output of the following code?

String s = new string();

System.out.println(“s = “ + s);

  1. What will be the output of the following code snippet?

int x= 10;

int y = 20;

if ((x<y)||(x=5) > 10)




  1. State the output of the following program:

public static void main(String args[ ])


int x = 10;

int y = 15;

System.ou.println((x>y)? 3.14: 3);


  1. State the output of the following program:

public static void main(String args[ ])


int x = 10;

float y = 10.0;

System.ou.println((x>y)? true: false);


  1. Given a pacakage named EDU.student, how would you import a class named Test contained in this package? Write one line statement.
  1. Consider the following class definition:

Class Student


abstract double result( )


This code will not compile since a keyword is missing in the first line. What is the




1.What does getPassword() on a password field return?

(a) a string (b) an integer (c) a character array.

Ans: (c) a character array

  1. Which of the following component is the best suited to accept the country of the user?
  1. List B. Combo box C. Radio button D. Check box

Ans: B. Combo box

  1. What command do you need to write in actionPerformed() event handler of a button, in order to make it exit button?
  1. System.out.println(); b. System.exit(0); c. System.out.print()

Ans: b. System.exit(0);

4.What method would you use, in order to simulate a button’s(namely Okbtn) click event, without any mouse activity from user’s side?

  1. Okbtn.setText() b.Okbtn.getText() c. Okbtn.doClick()

Ans: Okbtn.doClick()

  1. What would be the name of the event handler method in the ListSelection listener interface for a list namely CheckList to handle its item selections?
  1. CheckListValueChanged() b. getSelectedValue() c. clearSelection()

Ans: a. CheckListValueChanged()

  1. Which control displays text that the user cannot directly change or edit?

a.TextField b. Checkbox c. Combobox d. Label

Ans: d.Label

7.Which control provides basic text editing facility?

a.TextField b. Checkbox c. Combobox d. Label

Ans: a. TexfField

  1. Occurrence of an activity is called:
  1. Function b. Class c. Object d. Event

Ans: d.Event.

  1. Which property is used to set the text of the Label?
  1. font b.text d. icon

Ans: b.text

  1. The object containing the data to be exhibited by the combo box by which property.
  1. editable b. model c.selectedIndex d.selectedItem

Ans: b. model

  1. What is GUI programming?

Ans: A GUI(Graphical User Interface) is an interface that uses pictures and other graphic entities along with text, to interact with user.

  1. How is swing related to GUI programming?

Ans: We can create a GUI application on Java platform using Swing API (Application Programming Interface), which is part of Java Foundation Classes(JFC).

  1. What property would you set to assign access key to a button?

Ans: mnemonic property is used to assign access key or shortcut (Alt + Key).

  1. Which method can programmatically performs the click action of a push button?

Ans: private void TestBtnActionPerfomed(java.awt.action.ActionEvent evt){ }.

  1. Which property would you set for setting the password character as ‘$’?


  1. Which method returns the password entered in a password field?

Ans: char [] getPassword().

  1. Which list property do you set for specifying the items for the list.

Ans: model

  1. Which method would you use to determine the index of selected item in a list?

Ans: int getSelectedIndex().

  1. Which method would you use to insert an item at specified index, in the list?

Ans: void setSelectedIndex( int index).

  1. How you can determine whether 5th item in a list is selected or not?

Ans: isSelectedIndex(4).

  1. Which method you would use to insert ‘Hello’ at 10th position in the Text Area control.

Ans:void insert(“Hello”, 9).

  1. Which method you would like to use to insert an Icon (picture) on a Push Button.

Ans: void setIcon(Icon).

  1. Which property would you like to set to make a Combo box editable?

Ans: editable.

  1. Name three commonly used properties and methods of the following controls.

(a) text field (b) text area (c) Check Box

Ans: (a) Properties: text, font, editable. Methods: void setText(), String getText(), void


(b) Properties: enabled, editable, wrapStyleWord Methods: setText(), getText(), isEditable()

(c) Properties:font, text, selected . Methods: getText(), isEnabled(), isSelected().

  1. What is the difference between-

(a) Text field & Text area

(b) Text field & password field

(c) Radio Button & Check Box

Ans: (a) A text field’s text property can hold single line of text unless it is an HTML text. While a text area’s text can hold any number of lines of text depending upon its rows property.

(b) Though a text field and a password field can obtain a single line of text from the user, yet these are different. A password field displays the obtained text in encrypted form on screen while text field displays the obtained text in unencrypted form.

(c) Radio Button: A jRadioButton control belongs to JRadioButton class of Swing controls. It is used to get choices from the user. It is grouped control, so that only one can be selected at a time among them. Radio Button works in group, so that they must be kept in a ButtonGroup container control like so that only one can be selected at the same time.

Some features of jRadioButton control are-

_ It can be used to input choices typed input to the application.

_ Only one Radio button can be selected at a time.

_ They must be kept in a Button Group container control to form a group.

Check box: A jCheckBox control belongs to JCheckBox class of Swing controls. It indicates whether a particular condition is on or off. You can use Check boxes to give users true/false or yes/no options. Check Boxes may works independently to each other, so that any number of check boxes can be selected at the same time.

Some features of jCheckBox control are-

_ It can be used to input True/False or Yes/No typed input to the application.

_ Multiple check boxes can be selected at the same time.

  1. What is the significance of following properties of a text area ?

(a) lineWrap (b) wrapStyleword

Ans: (a) Defines Wrapping featureenable/disable (b) Determines where line wrapping occurs. If true, the component attempts to wrap only at word boundaries. This property is ignored unless linewrap is set to true.

  1. What is the significance of a button group? How do you create a button group?

Ans: We must add a ButtonGroup control to the frame to group the check boxes by using Button

Group property of the check box. By dragging buttongroup control from palette window.

  1. What do you understand by focus?

Ans: A Focus is the ability to receive user input/response through Mouse or Keyboard. When object or control has focus, it can receive input from user.

ı An object or control can receive focus only if its enabled and visible property are set to true.

ı Most of the controls provides FOCUS_GAINED() and FOCUS_LOST() method in FocusEvent by the FocusListener. FOCUS_LOST() is generally used for validation of data.

ı You can give focus to an object at run time by invoking the requestFocus() method in the code.

Ex. jTextBox2.requestFocus();

  1. What is meant by scope of a variable?

Ans: In Java, a variable can be declared any where in the program but before using them.

ı The area of program within which a variable is accessible, known as its scope.

ı A variable can be accessed within the block where it is declared.


int x=10;

if (a>b)

{ int y=5;

………… Scope of x and y



{ int z=3;

……. Scope of z




  1. Create a Java Desktop Application to find the incentive (%) of Sales for a Sales Person on the basis of following feedbacks:

Feedback Incentive (%)

Maximum Sales

Excellent Customer Feedback

Maximum Count Customer




Note: that the sales entry should not be space.Calculate the total incentive as :Sales amount* Incentive. The feedback will be implemented in JCheckBox controls.Using a JButton’s (Compute Incentive) click event handler,display the total incentives in a JTextField control. Assume the nomenclature of the swing components of your own.

Note that the JFrame from IDE window will be shown as given:

Ans:- private void btnIncActionPerformed (java.awt.ActionEvent evt) {

int sales = 0;

if (! txtSales.getText( ).trim( ).equals( “”)){

sales-Integer.parseInt(txtSales.getText( ).trim ( ));


double incentive = 0.0;

if (jCheckBox1.isSelected ( )) {

incentive = incentive + 0.1;


if (jCheckBox2.isSelected ( )) {

incentive = incentive + 0.8;


if (jCheckBox3.isSelected ( )) {

incentive = incentive + 0.05;


txtInc.setText ( “ “ + Math.round(sales * incentive));


  1. Assume the following interface built using Netbeans used for bill calculation of a ice-cream parlor. The parlor offers three verities of ice-cream – vanilla, strawberry, chocolate. Vanilla icecream costs Rs. 30, Strawberry Rs. 35 and Chocolate Rs. 50. A customer can chose one or more ice-creams, with quantities more than one for each of the variety chosen. To calculate the bill parlor manager selects the appropriate check boxes according to the verities of ice-cream chosen by the customer and enter their respective quantities. Write Java code for the following:
  1. On the click event of the button ‘Calculate’, the application finds and displays the total bill of the customer. It first displays the rate of various ice-creams in the respective text fields. If a user doesn’t select a check box, the respective ice-cream rate must become zero. The bill is calculated by multiplying the various quantities with their respective rate and later adding them all.
  1. On the Click event of the clear button all the text fields and the check boxes get cleared.
  1. On the click event of the close button the application gets closed.

Ans: (a)

private void jBtncalculateActionPerformed(java.awt.event.ActionEvent evt)























int r1,r2,r3,q1,q2,q3,a1,a2,a3,gt;

















private void jBtnClearActionPerformed(java.awt.event.ActionEvent evt)















Ans: (c)

private void jBtncloseActionPerformed(java.awt.event.ActionEvent evt)




  1. Read the following case study and answer the questions that follow.

TeachWell Public School wants to computerize the employee salary section.

The School is having two categories of employees : Teaching and Non Teaching. The Teaching

employees are further categorized into PGTs, TGTs and PRTs having different Basic salary.

The School gives addition pay of 3000 for employees who are working for more than 10 years.

Employee Type Basic    Salary      DA                              HRA                           Deductions

 (% of Basic Sal)      (% of Basic Sal)            (% of Basic sal)

Non Teaching                      12500 31                               30                                            12

PGT                                        14500 30                                21                                            20

TGT                                         12500 30                                30                                            25

PRT                                        11500 12                                12                                            12

 (a) Write the code to calculate the Basic salary, deductions, gross salary and net salary based on the given specification. Add 3000 to net salary if employee is working for more than 10 years.

Gross salary=Basic salary + DA + HRA

Net salary = Gross salary – deductions

(b)Write the code to exit the application.

(c)Write the code to disable textfields for gross salary, deductions and netsalary.

Ans: (a)

double bs=0,da=0,net=0,ded=0,gross=0,hra=0;

if (rdnon.isSelected()==true)







else if (rdpgt.isSelected()==true)







else if (rdtgt.isSelected()==true)







else if (rdprt.isSelected()==true)








net = gross – ded;





tfded.setText(“ ”+ded);

tfgross.setText(“ ”+gross);

tfnet.setText(“ ”+net);

tfbs.setText(“ ”+bs);







  1. ABC School uses the following interface built in java to check the eligibility of a student for a particular stream from science, commerce and humanities. The user first enters the total percentage and selects the desired stream by selecting the appropriate option button. An additional 5% is marks is given to students of NCC. Write Java Code for the following
  1. On Action event of the button ‘Calc Percentage’ Net percentage of the student is

calculated and displayed in the appropriate text filed. Net percentage is same as that of

the actual percentage if the student doesn’t opts for NCC otherwise 5% is added to actual percentage.

  1. On Action event of the button ‘Result’, the application checks the eligibility of the

students. And display result in the appropriate text field. Minimum percentage for science is 70, 60 for commerce and 40 for humanities.

  1. On the Click event of the clear button all the text fields and the check boxes get cleared.
  1. On the click event of the close button the application gets closed.



private void jBtnCalcPerActionPerformed(java.awt.event.ActionEvent evt)


int p;


if (jCheckBox1.isSelected())





private void jBtnResultActionPerformed(java.awt.event.ActionEvent evt)


int p;


if( jRadioButton1.isSelected())


if ( p>=70)

jTextField4.setText(“Eligible for all subject”);


jTextfield4.setText(“Not Eligible for science”);


else if( jRadioButton2.isSelected())


if ( p>=60 )

jTextField4.setText(“Eligible for Commerce and Humanities”);


jTextfield4.setText(“Not Eligible for Science and Commerce”);




if ( p>=40 )

jTextField4.setText(“Eligible for Humanities”);


jTextfield4.setText(“Not Eligible for any subject ”);




private void jBtnClearActionPerformed(java.awt.event.ActionEvent evt)


jTextField1.setText(“ “) OR jTextField1.setText(null)

jTextField1.setText(“ “) OR jTextField1.setText(null)

jTextField1.setText(“ “) OR jTextField1.setText(null)

jTextField1.setText(“ “) OR jTextField1.setText(null)




private void jBtnCloseActionPerformed(java.awt.event.ActionEvent evt)




Unsolved Questions:

  1. Describe the relationship between properties, methods and events.
  1. What is a container tag?
  1. What does a getPassword() method of a password field returns?
  1. What will be the contents of jTextArea1 after executing the following statement: 1
  1. jTextArea1.setText(“Object\nOriented\tProgramming”);
  1. What is difference between jRadioButton and jCheckBox?
  1. What does a JList fire when a user selects an item?
  1. What is Layout Manager? Discuss briefly layout managers offered by NetBeans?
  1. Name three commonly used properties and methods of the following controls.
  1. (a) text field (b) text area (c) label (d) Check Box (e) button.
  1. What is dispose of () used for?
  1. What is the difference between-
  1. (a) Text field & Text area
  1. (b) List & Combo
  1. (c) Radio Button & Check Box
  1. What is the significance of following properties of a text area?
  1. (a) lineWrap (b) wrapStyleword
  1. What is the significance of a button group? How do you create a button group?
  1. Discuss some commonly used properties of lists and combo boxes.
  1. What methods obtain the current selection of a combo box ? Give a code example.
  1. The FOR U SHOP has computerized its billing. A new bill is generated for each customer. The shop allows three different payment modes. The discount is given based on the payment mode.
  1. a) Write the code for the CmdClear Button to clear all the Text Fields.
  1. b) Write the code for the CmdCalc Button to display the Discount Amount and Net Price in the TxtDisc and the TxtNet Text Fields respectively.

These are some of the best Class 12 IP Viva Questions and answers if you need any other help in this case just drop your comment.

Print Friendly, PDF & Email

Related Posts

If you like CBSEToaday and would like to contribute, you can also write an article using submit article or mail your article to See your article appearing on the main page and help other students/teachers.