Unit - 1 COMUTER NETWORKING Level – 1 Ans 1: A computer network is a system in which computers are connected to share information and resources. Ans 2: In computer networking, a Media Access Control address (MAC address) is a unique identifier assigned to most network adapters or network interface cards (NICs) by the manufacturer for identification, and used in the Media Access Control protocol sub-layer. Ans 3: A unique number consisting of 4 parts separated by dots, e.g. 165.113.245.2 Every machine that is on the Internet has a unique IP number - if a machine does not have an IP number, it is not really on the Internet. Ans 4: Network can be classified on the basis of their size, complexity and geographical spread. On the basis of geographical spread it can be classified as Local Area Network, Metropolitan Area Network and Wide Area Network. Ans. 5: Network topology is defined as the interconnection of the various elements (links, nodes, etc.) of a computer network. In computer networking, topology refers to the layout of connected devices. Bus topology Star topology Ring topology Tree topology Mesh topology Ans 6: The central connecting device in a computer network is known as a hub. When data packets arrives at hub, it broadcast them to all the LAN cards in a network and the destined recipient picks them and all other computers discard the data packets. Ans 7: A Switch is a device that is used to segment networks into different sub networks called subnets or LAN segments. Segmenting the network into smaller subnets, prevents traffic overloading in a network. Page 1 of 36 Ans: 8. Goals of network: Resource sharing: The aim to make all programs, data and peripherals available to anyone on the network irrespective of the physical location of the resources and the users. Reliability: A file can have copies on two or more machines, so if one of them is unavailable due to hardware or software crash, the other copies could be used. E.g.: Railway reservation, Airways reservation etc. Cost Factor: Personal computers have better price / performance ratio as the important data are stored on file server machine available for sharing. Communication Medium: Using a network, it is possible for managers, working far apart, to prepare financial report of the company. The changes at one end can be immediately noticed at another and hence it speeds up co-operation among them. Ans 9: Network topology is defined as the interconnection of the various elements (links, nodes, etc.) of a computer network. In computer networking, topology refers to the layout of connected devices. o Bus topology o Star topology o Ring topology o Tree topology o Mesh topology Ans 10: Star topology is widely use due to following reasons: i. The star topology is considered the easiest topology to design and implement. ii. An advantage of the star topology is the simplicity of adding additional nodes. Ans 11: A hub is hardware device used to connect several computers together. It is of two types Active or passive Hubs. Active hub is one which amplifies the signal as it moves from one connected device to another. Passive hub allows the signal to pass from one computer to another computer without any change. Ans.12: Repeater is a device used in data communication to strengthen a signal as it is passed along the network cable. There are two types of Repeater: Amplifier: It amplifies all incoming signals as well as concurrent noise. Repeater: It regenerates the packet as if it is starting from the source station. Page 2 of 36 Level – 2 Ans. 1: Advantages: I. Data or information can be shared among the users. ii. Fast communication can be achieved. iii. Expensive hardware or software can be shared among the users. Ans: 2 Disadvantages of networks: i. Sophisticated Hardware and software technology is required. ii. Threat to security of data and information. Ans 3.Communication channels mean the connecting cables that link various workstations. There are 3 basic types of cables: Twisted Pair cables Coaxial cables Fiber-optic cables Ans 4: The unique name that identifies an Internet site. Domain Names always have 2 or more parts, separated by dots. The part on the left is the most specific, and the part on the right is the most general. E.g.: matisse.net Ans. 5: A metropolitan area network (MAN) is a large computer network that usually spans a city or a large campus. WAN is a network that covers an area larger than a single building or campus such as across the cities or countries. Ans 6: Cost of Expenses required for implementation of network, Reliability of a particular topology and flexibility of system for future adjustment; are the various factors that must be considered before making a choice for the topology. Ans 7: i. A twisted pair cable is incapable carrying a signal over long distances without the use of repeaters. ii. Its low bandwidth capabilities are unsuitable for broadband applications. iii. Its supports maximum data rates 1mbps without conditioning and 10 mbps with conditioning. Ans 8: Application of networks: 1. Sharing Computer peripherals among the connected users. 2. Sharing Data or information among the connected users. 3. Access to remote database: User can access to remote database sitting at his home to make reservation for airplanes, trains hotels and so on anywhere in the world with instant confirmation. 4. Communication facilities: Using Network, user can share text, images, digitized voice or movie to any users anywhere in the world. Page 3 of 36 5. Cost deduction: Using Computer Network communication system, amount required for travelling of user or data from one location to another can be reduced to very less and also saves energy for the same. Ans 9 (i): Optic fiber: Advantage: i. It is free from electrical noise and interference ii.It has more bandwidth than copper wire. Disadvantage: It is an expensive communication medium. Ans 9(ii) Coaxial cables: Advantage : i. It provides a cheap means of transporting multi-channel television signals around metropolitan areas. Disadvantage: Expensive than twisted pair cables. Ans 9(iii) Twisted pair cables: Advantage: It is inexpensive. It is easy to install and maintain. Disadvantage: It has low bandwidth capabilities. It is unsuitable for broadband connection. Ans 9(iv) Radio Wave: A data transmission by use of radio frequencies is called as radio-wave transmission. Advantages: i. Radio waves transmission offers mobility. ii. It proves as cheaper communication system. iii. It offers ease communication over difficult terrain. Disadvantages: i. It is an insecure communication system. ii. Radio Signals are susceptible to weather condition like thunder storms, rains etc. Ans 9(v): A microwave communication system is a communications system that uses a beam of radio waves in the microwave frequency range to transmit video, audio, or data between two locations, which can be from just a few feet or meters to several miles or kilometers apart. Microwave links are commonly used by television broadcasters to transmit programmes across a country, or from an outside broadcast back to a studio. Advantage: i. It is cheaper communication system ii. . It offers ease communication over difficult terrain. iii. It offers ease communication over oceans. Disadvantage: i. It is an insecure communication system. Page 4 of 36 ii. Radio Signals are susceptible to weather condition like thunder storms, rains etc. iii. Signals from single antenna may split up and propagate in slightly different path and hence reduces the signal strength. Ans 10: A Switch is a device that is used to segment networks into different sub networks called subnets or LAN segments. Segmenting the network into smaller subnets, prevents traffic overloading in a network. A switch is responsible for filtering i.e. transforming data in a specific way and for forwarding packets (a piece of message) between LAN segments. Switch support any packet protocol. LANs that are segmented through switches are called switched LANs. Ans 11: Denial-of-services attacks: DoS are those attacks that prevent the legal users of System from accessing or using the resources, information or capabilities of the system. It may be of following types: Denial of Access to Information: Such attacks cause deletion or changing of important information to non readable format. Denial of Access to Applications: Such attacks make the applications unusable or unavailable for legal user of the system. Denial of Access to Communications: Such attacks includes cutting of communication wire, jamming radio communications, flooding a system with junk mail. Level – 3 Ans 1: Cost of Expenses required for implementation of network, Reliability of a particular topology and flexibility of system for future adjustment; are the various factors that must be considered before making a choice for the topology. Ans 2: In bus topology each machine is connected to a single cable. Each computer or server is connected to the single bus cable through some kind of connector. Tree topology is a network with the shape of an inverted tree in which a single link between two nodes. Ans 3: In case if we need less connection of wires, very fast communication speed; a ring topology becomes the best choice for a network. This is because optical fiber offers the possibility of very high seed transmissions in one direction. Ans: 4 i. The star topology is considered the easiest topology to design and implement. ii. An advantage of the star topology is the simplicity of adding additional nodes. Ans 5: Denial of Service: It refers to any threat that prevents the legitimate users from accessing the network resources or processing capabilities. Page 5 of 36 Snooping: It refers to any threat that results in an unauthorized user obtaining information about a network or the traffic over that network. Ans 6: Domain Name Resolution is the task of converting domain names to their corresponding IP address. This is all done behind the scenes and is rarely noticed by the user. When you enter a domain name in an application that uses the Internet, the application will issue a command to have the operating system convert the domain name into its IP address, and then connect to that IP address to perform whatever operation it is trying to do. Ans 7: Communication channels mean the connecting cables that link various workstations. There are 3 basic types of cables: Twisted Pair cables Coaxial cables Fiber-optic cables Coaxial Cables: A cable consisting of two concentric conductors (an inner conductor and an outer conductor) insulated from each other by a dielectric; commonly used for the transmission of highspeed electronic data and/or video signals. Fiber Optic Cables: It is flexible optically transparent fiber, usually made of glass or plastic, through which light can be transmitted by successive internal reflections. Twisted Pair: A cable composed of two small insulated conductors twisted together without a common covering. Also known as copper pair. Twisted pairs have less bandwidth than coaxial cable Ans 8: The various threats to network security are as follows: 1. Intrusion Problems / Access Attacks: This occurs when an unauthorized user attempts to protected sensitive / confidential information. It may be of following types: a. Snooping: It refers to unauthorized access to someone else’s data, email or computer activity. b. Eavesdropping: It refers to unauthorized listening / intercepting someone else’s private communication / data/ information. 2. Denial-of-services attacks: DoS are those attacks that prevent the legal users of System from accessing or using the resources, information or capabilities of the system. It may be of following types : a. Denial of Access to Information: Such attacks causes deletion or changing of important information to non readable format. b. Denial of Access to Applications: Such attacks makes the applications unusable or unavailable for legal user of the system. Page 6 of 36 c. Denial of Access to Communications: Such attacks includes cutting of communication wire, jamming radio communications, flooding a system with junk mail. Ans 9: Threats of network security can be prevented by using various techniques: i. Authorization: In this case User is asked to enter an authorized login-id. If user is able to provide legal login-id then he/she is considered as authorized user. ii. Authentication: In this case User is asked to enter a legal password. If user is able to provide legal password then he/she is considered as authenticate user. iii. Firewall : Firewall is a mechanism to prevent unauthorized internet user to access private network connected to internet. iv. Intrusion Detection: This is a monitoring system which detects unauthorized access of data or resources of the network. Ans 10. Telephone Cable, Ethernet Cable, Co-axial Cable, Optical Fiber Topic- OSS LEVEL I Ans1. Free Software: Free software means the software is freely accessible and can be freely used, changed improved, copied and distributed by all who wish to do so. And no payments are needed to be made for free software. Open Source Software: can be freely used but it does not have to be free of chage. Here the company constructing the business models around open source software may receive payments concerning support, further development Ans2. The technical standards can be broadly of two types: (1). Proprietary standards (2). Open standards Ans3. Free software means the software is freely accessible and can be freely used ,changed Improved, copied and distributed by all who wish to do so.And no payments are needed to be made for free software. Ans4. COMMON OPEN STANDARD FORMATS 1. Plain text(ASCII) . 2. Hypertext Markup Language(HTML). 3. TeX,LaTeX and Device Independent Formats(DVI) 4. DVIng 5. Open Documents Format for Office Application (ODF) 6. Joint Photographic Expert Group. 7. Portable Network Graphic(PNG). 8. Scalable Vector Graphic (SVG). 9. Ogg Vorbis. 10. Free Lossless Audio Codec(FLAC) Ans6. ODF is open document format is an XML based file format for representing electronic documents such as spreadsheets , graphics etc. Ans7. A font refers to a set of displayable text characters (called glyphs ) , having specific style and size. Page 7 of 36 Ans8. Unicode provides a unique number for every character , no matter what the platform ,no matter what the platform ,no matter what the program ,no matter what the language. Ans9. Fonts can be categorized on the basis of two parameters: 1. On the basis of technical specifications. 2. On the basis of font configuration LEVEL II Ans1. Indian Standard Code for Information Interchange was evolved by a standardization committee .This is an eight bit code capable of coding 256 characters . ISCII code retains all ASCII characters and offers coding for Indian script also.It is also called Indian scripts Codes for Information Interchange Ans2 1) odt – for word processing 2). Ods – for for spreadsheet file 3). Dop – for electronic presentations files 4). Odg – for graphics file 5). Odb – for database file. Ans 3: Mozilla Freeware ► No source code available ► free internet software It can be download from www.mozilla.org Ans.4: APACHE: It is the most common web server (or HTTP server) software on the Internet. Apache is designed as a set of modules, enabling administrators to choose which features they wish to use and making it easy to add features to meet specific needs including handling protocols other than the web-standard HTTP. ► Apache HTTP server is an open source web server. ► It is component of LAMP. Ans 5.POSTGRE SQL: PostgreSQL is a free software Object Relational Database Server. It offers alternative to OOS database such as MySQL, and Firebird as well as proprietary Software such as Oracle, Sybase and Microsoft Sql Server. Ans.6: PHP: It is a Hypertext preprocessor language which is OSS used for server side applications and developing dynamic web content. PHP allows easy interaction with large number of relational database systems such MySQL, Oracle, DB2, PostgreSQL etc. PHP runs on most major OS including windows, Mac OS X, UNIX, Linux etc. Ans7.(1) Recipient may not be able to read all the file. (2)You may transmit confidential information (3)Single supplier or vendor has total control over the functionality and usefulness of the product. LEVEL III Ans.1 In two different ways ,Indian script can be entered : (i) (ii) Using phonetic text entry Using keymap based entry. Ans.2 It is Office an application suite which is free software and directly competes with Microsoft Office. It is compatible with MS Operating System, UNIX, MAC OS. Ans3. LAMP stands for Linux,Apache,Mozilla and PHP. Ans4.Pango project is to provide and open – source framework for the layout and rendering of internationalized text into GTK+ or GNOME environments. Ans.5 Convert each 7-bit code to its hex equivalent.The results are 48 45 4C 50 After locating these hex values in ASCII table we have H E L P Page 8 of 36 Ans6.Unicode provides a unique number for every character ,no matter what the platform ,no matter what the program , no matter what the language .The Unicode standard has been adopted by industry leaders such as Apple ,HP,IBM etc. Ans.7Words typed as per their pronounciation in English script and lator converted to Corresponding language word ,is known as Phonetic Text Entry or Transliteration. Ans8. Ogg Vorbis is freely available open format for audio streaming , without any restrictions.The other formats available today such as MP3,AAC of MMPEG – 4 etc. are available under certain terms. Ans.9 W3C is acronym for World Wide Web Conosrtium.W3C is responsible for producing the software standards for world wide web.It was created in October 1994. UNIT-II Java GUI Programming Revision Tour – I S. No. Degree of Importance Netbeans Java ** IDE Level 2 Basics of GUI * L1 3 Tokens * L1 4 Data Types *** L1,L2 5 Variables ***** L2, L3 6 Text Interactions Operators in Java Expressions **** L1, L2 ***** L1, L2 **** L1, L2,L3 Programming Constructs ***** L2, L3 1 7 8 9 Concept L1,L-2 Errors generally committed Not use appropriate component Wrong properties used Wrong identification Appropriate data types not used Wrong Declarations Proper syntax errors Wrong evaluation Semicolon not used Loop termination errors References Level - 1 Ans1. Rapid Application Development describes a method of developing software through the use of pre-programmed tolls or wizards. Ans2. Events are activities that take place either due to user interaction or due to some internal changes e.g. user clicks upon a command button or text of a textbox changes owing to a calculation. Ans3. A message is the information/request sent to an application about the occurrence of an event Ans4. Properties are characteristics of an object that control its appearance and /or behavior. Ans5. Identifier are fundamental building blocks of a program and are used as the general terminology for the names given to different parts of the program e.g. variables, objects, classes, functions etc. Ans6. Keywords are the reserved word in java and having a special purpose and they cannot be used for any other purpose. Page 9 of 36 Ans7. GUI stands for Graphical User Interface. This programming style involves graphics entities, rather than writing numerous lines of code. Ans8. Execution of multiple cases after matching takes place in a switch statement. Ans9. Unicode Ans10. Class new else try Level – 2 Ans1. Statement that unconditionally transfer program control with in a function. Ans2. int i= 0; for(i=51; i<=60; i++) { System.out.print(i + “ “); } Ans3. In a switch statement, after matching case’s code is executed, it stop only when it encounters break or closing brace ( } ) of switch. So, break statement acts as terminating statement for matched case in a switch statement. Ans4. Operators are the symbol that defines what kind of operation is to be done. Operators required operands to perform operations. 1. Unary operators 2. Binary operators 3. Ternary operators Ans5. 2 Ans.6. = 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. Ans.7. Two selection statement available in java are ‘if’ and ‘Switch’ Ans8. Difference between while and do while loop While Loop Do while Loop While Loop is a entry control Do while is a exit control loop loop int x= 100; int x= 100; while (x> 0) do { { System.out.println(X); System.out.println(X); X= x- 10; X= x- 10; } } while (x> 0); Ans9. 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; Ans.10.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. Page 10 of 36 Level -3 Ans1. Application Programming Interface. Ans2. Although properties, methods and events do different things, yet they are interrelated. Properties can be thought of as an object’s attributes, methods as its actions, and events as its responses. Ans3.This programming style responds to the user events and is driven by the occurrence of user-events. Ans.4 (i) Sequence constructs (ii) Selection statement (iii) Iteration statement Ans5. Every loop has its elements that controls govern its execution. Generally, a loop has four elements that have different purposes. These elements are as given below: 1. 2. 3. 4. Initialization expression(s) Test Expression. Update Expression(s) The body of the loop Ans6. The switch statement must be controlled by single integer control variable, and each case section must correspond to a single constant value for the variable. The if else if combination allows any kind of condition after each if Ans7. Difference between an entry control loop and an exit control loop. Entry Control Loop Exit Control Lop It first checks or evaluates the It first evaluates the loop body terminating condition and then and then checks the terminating executes the loop body. condition. If the condition is found true the loop continues otherwise the loop stops. In case if the condition is false In case if the condition is false in first time only then the loop in first time only then the loop will not get execute even once. will still get execute at-least once. Ans8. Infinite Loop, hence it is not possible to find the final value of i Ans9. //Assumes that given number is available int variable n int fact = 1; for(int i=1; i<=n; i++) { Fact=fact*i; } Ans10. 69 Revision Tour - II Level-1 Ans1. System.exit(0); Ans2. OKBtn.doClick(); Ans3. For this we shall set the icon property to the path a specific image file and text property to specific text. Ans4. A combobox is a graphical control that displays a list of values in a drop-down list form. Ans5. (i) JList (ii) JComboBox Ans6. CheckListValueChanged( ) Ans7. By setting editable property of combo box, we can make it editable. Page 11 of 36 Ans8. (c) a character array. Ans9. 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. Ans10. A text fiels’s text property can hold single line of text unless it is an HTML text. A text area’s text can hold any number of lines of text depending upon its rows property. Level-2 Ans1. A button group is a group of controls out of which only one can be selected at a time. A button group is created through JButtonGroup component class of Java Swing. In a button group we can put radio buttons or push buttons Ans2. 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. Ans3. 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. Ans4. Comments are added to a program for the following purposes:1. Make the more readable and understandable 2. For future references We can add comments in a Java program in the following ways: 1. Adding // before the line which is to be commented. This can be used only for single line comments. 2. using a pair of /* and */ for multi-line comments. Ans5. 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 comma in the for loop. Ans6. Yes, it is possible to store a text in a jTextField in a Integer variable. To store the text, first it must be converted into intertype using the pareInt() method. int stud_cnt= Integer.pareInt(JTextFiled1.getText()); In the a above statement, first the getText() function obtains the text written in the jTextField1 and then convert it into integer type using parseInt() method of available in Integer class. Ans7. 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 Ans8. Keyword, Identifier, Literal, Punctuators ad Operators Ans9. 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. Ans10. Break is used to terminate the current switch statement or the loop. Page 12 of 36 Level-3 Ans1. A list is a graphical control that display a list of items in a box where from the user can make selection. A list is different from combobox in many ways: (i) A list does not have a text field the user can use to edit the selected item, whereas a combobox is a cross between a text field and a list. (ii) In a list user must select the items directly from the list whereas in a combobox user can edit it if he/ she wishes. (iii) The list does not drop down whereas a combobox takes less space initially but drop down when user clicks obn its arrow. (iv) List allow us to select more than obe items but combobox allows only single item selection. Ans2. Through a text field and a password field can obtain a single line of text from user, yet there are difference A password field displays the obtained text in encrypted form on screen while text field displays the obtained text in unencrypted form. Ans3. Top level containers: JFrame, JDialog Middle level containers: JPanel, JTabbedPane Component level containers: JButton, JLabel Ans4. A container is a control that can hold other controls within it e.g. a Panel, a Label, Frame etc. Controls inside a container are known as child controls. The child controls can exit completely inside their containers. When we delete a container control, all its child controls automatically get deleted. Ans5. An Event refers to the occurrence of an activity. Events can occure through user actions such as a mouse click or key press. Each time an event occurs, it causes a message to be sent to the operating system. Ans6. A GUI (Graphical User Interface) is an interface that use pictures and other graphic entities along with text , to interact with user. You can create a GUI application on Java platform using Swing API(Application Programming Interface), which is part of Java Foundation Classes (JFC). Ans7. 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) jCheckbox1.setSelected(false); } private void jBtnCalcPerActionPerformed(java.awt.event.ActionEvent evt) { int p; p=Integer.parseInt(jTextField2.getText()); if (jCheckBox1.isSelected()) p=p+5; jTextField3.setText(Integer.toString(p)); } private void jBtnResultActionPerformed(java.awt.event.ActionEvent evt) { Page 13 of 36 int p; p=Integer.parseInt(jTextField3.getText()); if( jRadioButton1.isSelected()) { if ( p>=70) jTextField4.setText(“Eligible for all subject”); else jTextfield4.setText(“Not Eligible for science”); } else if( jRadioButton2.isSelected()) { if ( p>=60 ) jTextField4.setText(“Eligible for Commerce and Humanities”); else jTextfield4.setText(“Not Eligible for Science and Commerce”); } else { if ( p>=40 ) jTextField4.setText(“Eligible for Humanities”); else jTextfield4.setText(“Not Eligible for any subject ”); } } private void jBtnCloseActionPerformed(java.awt.event.ActionEvent evt) { System.exit(0); } Ans8. Joption pane support the following Dialog types: a) Input Dialog: provides a text Field, Combo box or a list box for the user to input an option or value. b) Confirm Dialog: it helps the user to input the choice in the form of Ok, Cancel, Yes, No etc. c) Message Dialog: It is a simple dialog box to display a message with a OK button. Option Dialog: helps to create a dialog box according to the requirements of the user. Ans9. showInputDialog(): to display an Input dialog Box: showIConfirmDialog(): to display a confirm dialog Box: showMessageDialog(): to show a Message dialog Box: showOptionDialog(): to show a option dialog Box: Ans10. Various possible values for Option type property of jOptionPane are -1: used to display a simple OK Button. 0: To display both Yes and No button 1: To display Yes, No and Cancel button, 2: To display Ok and Cancel button. Page 14 of 36 UNIT-II Chapter- 5 JAVAGUI PROGRAMMING REVISION TOUR-III Level –I 1 Class 2 Yes 3 Non-Parameterized Constructor 4 Which can receive Parameters. Level- II 1 Whenever object is created. 2 when object is created and by using (.) Operator. 3 In Call by Value , The called method creates it’s own work copy for the passed parameters and copies the passes values in it. Any changes that take place are done in the work copy and the original data remain intact. In Call by reference, the called method receive the reference to the passed parameters and through this reference, it access the original data. Any changes that take place are reflected in the original data. Level- III 1 Constructor Properties are: (i) have no return type, not even void (ii) constructor should be defined as public, so that it’s objects can be created in any method. 2 The data type that are based on fundamental or primitive data type, are known as Composite data type. User Defied Data type are created by users. 3 Software objects have state and behaviour like their state is maintained through variables or data items. Their behaviour is implemented through functions generally called methods. Real World object also physical characteristics(or state) and behaviour e.g. a Motorbike has: Like: Current gear,two wheels are Characteristics Like: halting, accelerating are States 4 The keyword this refers to currently calling object. It is automatically created and initialized by java. So you can refer to current object by using keyword this. Answer to the Chapter -6 More about Classes and libraries Level 1 1 2 3 4 5 6 7 8 9 10 Length() return the length while capacity() return maximum no of character that can be entered. Return length , extract substring , conacat string specified in argument, removes the leading & trailing spaces, convert into upper & lowercase Java.applet , java.awt, java.io, java.net Abstract classes are used for inheritance Abstract classes are used for inheritance while interface is used for multiple inheritance Compareto () compares 2 string while equals( ) check for equality indexOf(char ch) returns the index of the Character Ch Power(a,b ) finds the value of a raise to power b Append() is used to append the string in a textarea to its p charAt(int a) retruns the character present at position a in the string Page 15 of 36 Level 2 1. 2. Related classes and interfaces grouped together is called as package. Member Type Its Own Derived Class class Same Package Public Accessible Accessible Accessible Protected Accessible Accessible Accessible Default Accessible Accessible Not Accessible Private Protected Accessible Accessible Not Accessible Private Accessible Not Accessible Not Accessible Other Package 3. Final keyword is used fro a class to make it static 4 Whenever a class contains only general code and need to be inherited . 5. (a) s.length() will give output -17 (b) jTextField2.setText(s.toLowerCase()) will give output abc micro systems 6 (a) 2 (b) 8 7. (a) ABC Microsytems (b) 3 ( c) 12 8. HBC 9. ABC Microsystems 10. 2 Level 3 1. string str = Tf.getText(); int len = str.length(); char ch =character.toUppercase(); str = ch + str.substring(1); for (int I =2 ;i<len -1; i++) { If (str.charAt(i) == ‘ ‘) { Ch = character.toupperCase(str.charAt(i+1)); Str = str.substring(0,i+1) + ch +str.substring(i+2); } } TF.setText(str); 2. string str = STF.getText(); char ch = charTF.getText().charAt(0); int count = 0; for(int i=0; i<str.length(); i++) { If(str.charAt(i) = = ch) Count=count+1; } occurLable.setText(“”+ Count); 3. string str = STF.getText(); string strRev = “”; Page 16 of 36 for(int i=str.length()-1 ;i>0 ; i--) { strRev=strRev+ str.charAt(i); } Revtf.setText(strRev); 4. i. abc ii. Abcxyz 5. CentralMadras 6. ABC Micto Systems 7. i INFORMATICS PRACTICES ii Informatics Practices 8. Informatics Practices Practicals 9. 20 10. SPACE In Chapter -7 Lesson-Inheritance Level 1 Ans-1 Inheritance: The ability of a class to obtain the characteristics of another class is called inheritance. Need of Inheritance: Inheritance helps in two ways: Code Reusability: Helps in expressing relationship among classes Ans -2 Type of Inheritance: o Single Inheritance o Multiple Inheritance o Hierarchical Inheritance o Multilevel Inheritance o Hybrid Inheritance Ans-3 Base Class (Parent Class): The Preexisting class which is being inherited is called the base class or the parent class. It is also called a Super Class Derived Class (Child Class): The new class which inherits the capabilities from another pre-existing class is called the Derived Class or the Child Class. It is also called Sub Class. Ans-4 Public, Protected Default, Private Protected, Private and their scopes Ans -5 Function Overriding: o If a derived class method has the same name as that of the base class then the derived class method overtakes (get higher preference) the base class method. This is known as overriding of base class method. Function overloading: Page 17 of 36 o Two or more functions in the same scope having the same name but different signatures are said to be overloaded. For two functions to be overloaded either they should have different number of arguments or different order of arguments. As-6 Abstract Class: A class that cannot be instantiated. Abstract Method: A method without implementation. As- 7 No Level-2 Ans -1 Type of Inheritance: o Single Inheritance: A single Base class is being inherited by a single derived class. o Multiple Inheritance: A single derived class inherits more than one base class.(This type of inheritance is not supported in Java) o Hierarchical Inheritance: A single base class is being inherited by more than one child classes. o Multilevel Inheritance: A child class act as a base class for anther child class. o Hybrid Inheritance: A combination of two or more of the above inheritance pattern. Ans- 2 No Ans- 3 Final class cannot be inherited. Final methods, classes are used for security. This is because Hackers extend some of important classes and substitute their classes for the origin. As-4 Abstract Class: A class that cannot be instantiated. public abstract class shape { --------- Ans-5 } An interface cannot implement any methods. No variables can be inherited from interfaces. Level 3 Ans 1 Reusability Page 18 of 36 Base Class & Derived Class Ans-2 A concrete/abstract superclass is the one whose objects cannot be declared and created. When we need to define general characteristics and behavior of its subclass es. Ans-3 a) An interface can be implemented by a class which is already a subclass of another class. A class which is already a subclass of another class can’t extend an abstract class as well. b) An abstract class can contain non abstract methods where as a interface can’t contain non-abstract methods. All methods of an interface must be abstract. Ans-4 Protected member is accessible in non sub class of same package but friendly is not Accessible. Ans-5 1. Create the class Student 2. Declare data members & functions 3. Create another class graduate and extend the Student class Ans- 6 It is determined by the type of the object being referred to at the time of call. Unit -2 ( Programming) Chapter – 8 ( GUI Dialogs and Tables) LEVEL 1 Ans 1: To provide or request information to / from the user. Ans 2: Table Ans 3: Yes Ans 4: Yes with associated TABLE_MODEL Ans 5: Allows displaying data in row column format. Ans 6: dispose() method. Ans 7: InputDialog Confirm Dialog Message Dialog Option Dialog LEVEL 2 Ans 1: A small separate window that appears to user. Ans 2: OK and CANCEL. Ans 3: Step 1: to get the table-model DefaultTableModel <name>= (DefaultTableModel) <table-name>.getModel(); Step2: tocount the rows Int r = <name>.getRowCount(); Step 3: to remove the indexed row. <name>.removeRow(index); Ans 4: import javax.swing.JOptionPane; Ans 5: setVisible(true); Page 19 of 36 Ans 6: float n1,n2; n1=23.45; n2=45.67; float ans=n1+n2; JOptionPane(ans); Ans 7: showMessageDialog showConfirmDialog showOptionDialog showInputDialog LEVEL 3 Ans 1: InputArea Icon Type Message Button Ans 2: it is associated object that provides source-data to a JTable Object. It is the tablemodel that organizes the source data in row-column format. Ans 3: int val =0; int sum=0; do { val=JOptionPane.showInputDialog(“Enter any Number”); sum=sum+val; }while(val <> 0); JOptionDialog.showMesageDialog(“The sum =” + sum); Ans 4: This command specifies question mark icon to be displayed alongwith the JOptionPane through message type property. Ans 5: The Message dialog (invoked with showMessageDialog()) does not return anything. UNIT 9:DATABASE CONNECTIVITY TO MYSQL Level 1: Ans1:Database Connectivity refers to connection and communication between an application and a database system. Ans2: JDBC: Java Database Connectivity is a framework developed by Sun Java to help Java connect to different databases ODBC:Open Database Connectivity is a framework used by Microsoft to connect to various types of databases. JDBC provides database connectivity from within Java application to databaseswhereas ODBCprovides databases connectivity to non-Java front end applications. But ODBC is language independent as it can work with any language but JDBC is language dependent as it works only for Java. Ans3:A resultset refers to a logical set of records that are fetched from the databases by executing a query and made available to the application program. Ans4: getInt(),getFloat(),getString(),getDate(). Ans 5: next(), first(), last(), relative(int rows), absolute(intrno), getRow() Page 20 of 36 Level 2: Ans1: Tasks: a) Establish a connection with a database. b) Sending SQL statements to database server c) Processing the results obtained Ans2: Connection: A connection is the session between the application program and the database. Role:To do anything with database one must have a connection object. Ans3:It is use to create an instance of a driver and register it with the DriverManager. Ans4: Consider following line of code: Connection con=DriverManager.getConnection (“jdbc:mysql://localhost:3306/test”,”root”,”pwd”); *pwd is the password assigned to your MySQl. Ans5: Statement object execute one static SQL statement on the associated database by executing a query and made available to the application program. Ans6:Class.forName(“com.mysql.jdbc.Driver”); Level 3: Ans1. a)Consider the Table DEPT(deptno,deptname,address). b) Provide connectivity URL. c)Use Java classes d)Store the Select query in a string. e) use method executeQuery() Ans2. Ans1. a)Consider the Table DEPT(deptno,deptname,address). b) Consider the buttons INSERT,DELETE,UPDATE and write the respective operations separately. b) Provide connectivity URL. c) Use Java classes d) Store the query in a string. e) use method executeQuery() and executeUpdate() Web Application Development LEVEL-1 1. It is software programs that allow to user to access and navigate www. (Internet Explorer,Mozilla Firefox, Google Chrome) 2. It is a software program that allows to user to access and navigate WWW. (Internet Explorer,Mozilla Firefox, Google Chrome),Web Server is a program that runs on the computer connected to the Internet and fulfils the request send by the web browser.(Ex. Apache Web Server, Netscape Enterprise Navigator). 3. In Client/Server Computing: - Client makes a request for services from another program and Server fulfils the request send by the clients. 4. A location on Net Server is called web site. 5. (a) Hypertext transfer protocol Page 21 of 36 (b) World wide web (c) Uniform resource locator (d) Computer generated imagery 6. Server-site 7. CGI 8. File 9. The WWW 10. Host LEVEL-II 1. Each website has a unique address called URL (uniform resource locator) its components are (a) The type of server or protocol e.g http (b) The name and address of the server. e.g MSN.com (c) Location of the file on the server e.g. encycle.msn.com/get info/style.asp 2. CGI scripts and Server Side Scripts are used to create dynamic WebPages. 3. The other server on the Internet:-ftp, gopher, cater to textual information but www uses http server caters to multimedia information. So it enables user to receive hypertext information. 4. FTP. (1 Mark for Abbreviation and/or Full Form) 5. A URL (Uniform Resource Locator) is the complete address of a document on the web, Whereas a domain name specifies the location of document's web server. A domain Name is a component of the URL used to access web sites. For example the web address http://www.example.net/index.html is a URL. LEVEL-III 1. Set of rules are called protocols. A file’s internet address or URL is determined by protocol. 2. Dynamic WebPages support client server concept i.e. any request are fulfilled by server while static WebPages does not support client sever concept. 3. The character based naming system by which servers are identified is known as domain name system. 4. HTTP 5. The above address is called IP address or Internet protocol address. It is numerical label that is assigned to devices participating in a network. Unit -2 ( Programming) Chapter –11 SOLUTION ( HTML:-Basic HTML elements) ANSWERS: LEVEL 1: 1. to create web pages. 2. HEAD tag 3. not case-sensitive 4. .html (dot html) 5. Body of html document is prepared in <BODY> tag 6. <BODY BGCOLOR=VBRED> LEVEL 2: 1. By usig <body> tag and its background attribute Page 22 of 36 2. 3. 4. 5. 6. Container tags have both starting and ending as well as empty tags have only starting tags. LEFT, RIGHT , CENTRE BGCOLOR, BACKGROUND <BODY> , BACKGROUND <P> tag is used for making paragraph and <BR> tag is used for break a line. LEVEL 3: 1. It lets you know the basic size for the font. Attributes- size, face 2. It is basically used for a short segment of text. 3. <HEAD> tag is used for giving title of the document and <BODY> tag is used for making body of the document. 4. <!------> 5. For giving different sizes of headings from h1 to h6 6. <SUP> TAG 7. Colspan is used for merging columns and rowspan is used for merging rows. Chapter 12 : HTML-II (Lists ,Tables and Forms) Level 1. 1 . The different forms of lists are: ordered and unordered lists. For example, UL and OL. 2. The <OL> tag is used to indicate a list item as contained in an ordered or numbered form. For example i. <OL> 1. <LI> Apples 2. <LI> Oranges ii. </OL> iii. Two attributes are: START, TYPE. 3. CELLPADDING tells the browser how much padding is required in the cell. In other words between the side of the cell and the contents of the cell. Try a few different numbers. Note that cell and padding run together and are one word. To control the horizontal alignment of text and images within table cells use the align attribute i.e., align=left, align=right or align=center. 1. CELLSPACING defines how much space you’d like in cells. It specifies the amount of space between the frame of the table and the cells in the table. Note that cell and spacing run together. 2. In a list, the TYPE attribute specifies the type of numbering (:A”, etc.) or bulleting (“circle”, “Disc”, Square”, etc.) depending on whether the LI is inside an OL or UL list. 3. The START attribute is used to change the beginning value of an ordered list. Normally, the ordered list starts with 1. for example, <OL START = 10> 4. It is used to define a set of header rows. 5. They are used to specify the span of a cell. 6. Align attribute is used to control the horizontal alignment of the contents of a cell. 7. They are indented lists with a specific bullet. Level 2: 1. Table is a collection of rows and column. Followings are important tags <Table> :- used to give identification to a table Page 23 of 36 <TH> :- To provide headings in a table <TR>:- (Table Row) to create Row in a table <TD> :- (Table Data) to create columns in a row 2. To create or use forms in a web page <FORM> tag is used. Form is means to collect data from the site visitor. It is done with the help of controls that collect data and send it over. Example: <FORM method = “POST” action=mailto:xyz.abc@gmail.com> 3. Text boxes are single line text input controls that are created using <INPUT> tag whose TYPE attribute has a value as “Text”. Example: <FORM method = “POST” action=mailto:xyz.abc@gmail.com> First Name: <INPUT TYPE=”text” NAME = “fname”/> <BR> Last Name: <INPUT TYPE=”text” NAME = “lname” /> </FORM> 4. <Input type =”radio” name=”stream” value= “science”/> 5. <Input type=”checkbox” name=”s2” value=”physics”/> 6. <text area=”5” cols=”50” name =”description”> 7. They are indented lists without any billet symbol or any number in front of each item. Level 3: 1. Sometimes a table cell is bigger than other. Its span is spread to more rows or columns. Such cells can be created with rowspan and colspan. For instance following code will produce the table shown below it in which cells have different span. <html> <body> <table border> <tr> <td align=center rowspan =2 colspan=2>a</td> <td>1</td> <td>2</td> </tr> 2. An HTML Form does not do anything without a program to process the information .We need to specify the following things in order to get the form processed. a) Where the processing program is located. b) How it takes information i.e. whether we need to use the POST or GET method. 3. When Submit button is clicked then the forms data is submitted to the back end application. When Reset button is clicked then all the forms controls are reset to default size. 4. GET sends the information to the URL specified through action attribute. Page 24 of 36 POST sends the form information in the HTTP environment. 5. <html> <body> <p align=center> <center><h1>example</h1></center> </p> <form method=post> <p> persons name: <input type="text" name="persons-name" size="40" maxlength="40"> <input type="hidden" name="recipient" size="40" maxlength="40"> </p> <p> password: <input type="password" name="password" size="10"maxlength="10"> </p> <p>please place me on your mailing list <input type="checkbox" name="mailing-list" value="yes" checked> </p> <p>what country do you live in? <select name="country"> <option value="ind">india <option value="usa">united states <option value="ca">canada <option value="fr">france <option value="spr">singapore </select> </p> <p>type of computer you have <input type="radio" name="comp-type" value="486dx">486dx&nbsp; <input type="radio" name="comp-type" value="486sx">486sx&nbsp; <input type="radio" name="comp-type" value="pentium2" checked > pentium 2 &nbsp; <input type="radio" name="comp-type" value="pentium3">pentium3&nbsp; <input type="radio" name="comp-type" value="pentium 4">pentium4 &nbsp; </p> <p> comments <input type="submit" name="request" value="submit this form"> <input type="reset" name="clear" value="clear form and start over"> </p> </body> </html> UNIT III Chapter-13 EXTENSIBLE MARKUP LANGUAGE Page 25 of 36 Level-I 1. Markup Language is a set of rules /tag that define the structure and format of text while Presenting text. 2. XML stands for eXtensible Markup Language. Which allows creating application specific structured document by allowing creation of new tags. 3. XML is used to describe what data actually means. 4. A meta-language is a language that’s used to define other language.XML is a meta language. Level-II 1. (i) ADML (Architecture Description Markup Language) (ii) GML (Geography markup Language (iii) MathMl(Mathematical Markup Language) 2. HTML XML 1 HTML document formats and XML documents carry data displays web page’s data along with their description. 2 HTML tags are predefined New tags can be created as per our requirements. 3 HTML may not have closing XML must have closing tags. tags. 4 HTML tags are not case XML tags are case sensitive. sensitive 5 HTML documents are directly XML documents are viewed only viewable in a browser. if proper style sheet file is also available along with XML file. 3. a. XML is designed to carry data not to display data. b. XML was created to structure, store and to send information. c. XML is self descriptive .Tags are not pre defined; rather they are created to describe the content in appropriate manner. d. XML is free and extensible. e. XML is platform independent. f. XML can separate Data from HTML.XML stores and describes data, which can later be formatted and presented in desired way. g. XML can be used to create new languages, since it is a meta language. h. XML is supported and recommended by World Wide Web Consortium (W3C). 4. XML Validator And XML parser Level-III 1. <?xml version=”1.0”> <message data=”9/10/2009> <sender>gurpreet</sender> <receivers> <receiver> Rehana </receiver> <receiver> Josheph </receiver> </receivers> <text>project successfully completed </text> </message> 2. The above XML document is not well formed. The document suffer from two errors: Improper nesting –The body element was opened inside the to element, yet body was not closed before the to element was closed. Page 26 of 36 Mismatched cases of start and end tags-The tag<sender> is closed with </Sender>, which is incorrect. XML is case sensitive, thus the end-tag of <sender> should be </sender> and not <Sender> My SQL Revision tour Level 1: 1. A Primary Key is a set of one or more attribute that can uniquely identify tuples within the relation. 2. A non key attribute, whose values are derived from the primary key of some other table, is known as foreign key in its current table. 3. Referential integrity is a system of rules that a DBMS uses to ensure that relationships between records in related tables are valid, and that users don't accidently delete or change related data. 4. No of tuples in a relation is known as degree and no of attributes in a relation is known as cardinality. 5. The columns in relation is known as attribute and the rows in a relation is known as tuple. 6. A virtual table derived from one of more underlying base tables. 7. A candidate key which is not primary key is known as alternate key. 8. The attribute combination in a relation that can serve as a primary key. Level 2: 1. . key features are: a.fast speed. b.Ease of use. c.Free of cost. d.Portability. e.Security f.Provides many datatypes. 2. The difference between CHAR and VARCHAR is that of fixed length and variable length.The Char datatype specifies a fixed length character string. when a clolumn is given datatype CHAR(n), then the lenght is fixed to n characters and if the value is less than n than blank is added, but the size remain n byte, where as VARCHAR, on the other hand, specifies a variable length string. 3. DDL stands for Data Definition Language, that allows you to perform tasks related to data definition. DML Stands for Data Manipulation Language, and are used to manipulate data. 4. My SQL is a free, open source Relational Database Management that uses structured query language. In a My SQL database, information is stored in tables. 5. select ename,empno from emp; 6. select ename,empno from emp; 7. select ename,sal,deptno from empl where comm is NULL; 8. select * from emp where sal*12 between 25000 and 40000; 9. select * from empl where comm>sal; 10. select ename from emp where ename like'_ _ A%'; LEVEL 3: 1. Answers are as following: a. create table club ( Member_No number(5) Primary key, Page 27 of 36 b. c. d. e. Member_Name varchar(40) not null, Address varchar(30), Age number(2) check(age>=18), Type varchar(10), Fees number(6,2)); insert into club values(101,‘reena’,’hissar’,24,’permanenet’,2000); insert into club values(102,‘meena’,’hissar’,24,’permanenet’,2000); select * from club where type= ‘permanent’ and fees>5000 alter table club add(phno integer); Update club Set fees=fees*.10 Where type= ‘temp’; f. 2. 3. 4. 5. Select * from emp Where age>=18; Answers are as follows: i. Select * from teachers where department=’HISTORY’ ii. SELECT name from teachers where department=’HINDI’ and sex=’F’ iii. Select name from teacher order by dateofjoin iv. Select * from teacher where salary between 20000 and 35000 v. Select name, age, department from teachers order by department vi. Select avg(salary) from teacher group by department vii. Select avg(salary) from teacher group by department viii. Select department, sum(salary) from teacher group by department sum(salary)>50000 ix. Select avg(sal), sex from teachers group by sex x. Desc teachers. The degree is 7 because the no of attributes are 7 and cardinality is 8 Now the degree will become 8 and cardinality will be 11. Answers are as follows: a. Select * from SchoolBus where capacity > noofstuents b. Select Area_covered from SchoolBus where distance>20 and Charges<8000 c. Select sum(Noofstudens), Transporter from SchoolBus group by Transporter d. Insert into SchoolBus values(11, ‘Moti bagh’,35,32,10,’ kisan tours ‘, 35000) having e. Run the query and check 6. Answers are as follows a. Select name from graduate where div=’I’ order by name; b. Select NAME, STIPEND, SUBJECT , 12*stipend from graduate; c. Select count(*) from graduate where subject=’physics’ or subject=’comp. sc’; d. Insert into graduate Values(11,’KAJOL’, 300, ‘computer sc’, 75, 1); e. Run the query and check 7. Answers are as follows: Page 28 of 36 a. Create table furniture ( Itemno int(5) primary key, Itemname varchar(20) not null, Type varchar(20) reference item(type), Dateofstock date default=’10-03-10’, Price int(6) check(price<40000), Discount int(2) not null); b. In delete command the name of the columns must not be given in the command. Database Transaction Level 2 1. Transaction : A transaction is a logical unit of work that must succeed or fail in its entirety. A transaction might be a sequence of many SQL statements, but logically performing a single task, thus all the SQL statements should work as a whole or none at all ensuring the consistency of the database. A transaction is an atomic operation which may not divided into smaller operations. 2. ACID properties : A database system must maintain the following four (Atomicity, Consistency, Isolation, & Durability) properties of a transaction: a) Atomicity : (All or None) This property ensures that either all operations of the transaction are executed or none at all. b) Consistency: This property implies that if the database is in consistent state before the execution of the transaction, database must remain in consistent state after the execution of the transaction. c) Isolation: This property suggests that if a transaction is being executed in the database system, no other transaction should be executed at the same time. It simply refers that if a transaction is accessing/modifying some data item, that data item must not be available to other transaction at the same time, since it may be in an inconsistent state. d) Durability : This property of transaction ensures that after the successful compeletion of the transaction the changes made by it to the database persist, even if there are system failures. 3. Commit: This command permanently commits all the changes made in the database after last commit command was executed. After committing the transaction, changes made can not be rolled back. RollBack : This command rolls back (undoes) all the changes made in the database after last commit command was executed. SavePoint : In between the transaction savepoints can be defined. If in any case rollback is needed but only a few operations are needed to be rolled back, savepoints are useful. Using the ROLLBACK TO command changes can be undone in reverse direction(last change to first change) upto specified SAVEPOINT. 4. DDL Statement. 5. Rollback undoes the previous changes and Commit does the changes permanently. UNIT-III Chapter-14 MYSQL REVISION TOUR Level-I Page 29 of 36 1. (i) 29, 33 (ii) kv pinjore 2. Reduce redundancy, Control inconsistency, Provide security and protection. 3. Drop table means delete the entire table and drop database means delete the database with all its tables. 4. A non key attribute of the relation that is foreign key of the other table and primary key for first table 5. It is multithreaded Open source RDBMS. 6. Single row function individual result for each row where as aggregate function gives aggregated result for the given group of rows. 7. To perform any aggregate operation in groups, we use GROUP BY clause with the Select statement 8. According to table (i) Select * from teachers where department=’HISTORY’; (ii) SELECT name from teachers where department=’HINDI’ and sex=’F’ (iii) Select name from teacher order by dateofjoin (iv) Select * from teacher where salary between 20000 and 35000 (v) Select name, age, department from teachers order by department (vi) Select avg(salary) from teachers (vii) Select avg(salary) from teacher group by department (viii) Select department, sum(salary) from teacher group by department having sum(salary)>50000 (ix) Select avg(sal), sex from teachers group by sex (x) Desc teachers Level-II It maintains the integrity of the Database. It does not allow any data to be deleted accidentally. A primary key is used to uniquely identify each row in a table. NOT NULL constraint ensures that a column cannot have NULL value. Example: CREATE TABLE STUDENT (ROLLNO INT PRIMARY KEY, FNAME VARCHAR(20) NOT NULL, LNAME VARCHAR(20) ); Or CREATE TABLE STUDENT (ROLLNO INT, FNAME VARCHAR(20) NOT NULL, LNAME VARCHAR(20) PRIMARY KEY (ROLLNO) ); DDL commands:- These are data definition language that are use to create table, views, indexes schemas. E. g. create, alter, drop DML Commands:- Thaese are data definition language that are used for update, insert and delete the data from table. E. g. insert, update, delete Char :- A fixed-length string between and 255 characters in length right-padded with spaces to the specified length when stored values must be enclosed in single quotes or double quotes. Varchar:- A variable-length string between 1 and 255 characters in length; for example VARCHAR(25).Values must be enclosed in single quotes or double quotes. More on SQL Page 30 of 36 Level 1 1. Rules that are defined when a table is created. They help in preventing certain type of inconsistent values from being placed in the column(s). 2. 3. 4. 5. 6. 7. 8. 9. 10. Constraints name Description PRIMARY KEY Used to create a primary key UNIQUE to create a unique key NOT NULL to define that column will not accept null values. FOREIGN KEY/ REFERENCES to define referential integrity with another table. DEFAULT to define the columns default value. CHECK to define the custom rule. A Primary key constraint uniquely identifies each row in a table which means that no two rows in a table can have same values. No, only one primary key constraint can be created for each table. Foreign key enforces referential integrity. A foreign key column is one whose values are derived from primary key column of another table. Yes, a table can have multiple foreign keys. A NOT NULL constraint enforces that the column will not accept NULL values. Unique and NOT NULL Create table table-name(column-name data-type(size) primary key….); It limits the values that can be inserted into a table eg. The age entered by user must be greater than 18 When a user does not enter a value for the column (having default value), automatically the defined default value is inserted in the field Drop table table-name; Answers Level 2 1. 2. 3. 4. Alter table Select * from book where price IS NULL; Roll Number Column constraints apply to individual columns whereas table constraints apply to group of one or more columns 5. A composite primary key is made up from combination of columns and it can be defined as only a table integrity constraint. 6. It states that if a DELETE or UPDATE operation affects a row from parent table, then automatic delete or update is made in matching rows of child table. 7. a) Alter table <tablename> ADD [column] <columnname> <datatype>; b) Alter table <tablename> modify [column] <columnname> <column definition>; c) Alter table <tablename> drop [column] <columnname>; 8. Yes, with alter command. Alter table <tablename> add primary key(columnname); 9. Yes. Alter table <tablename> drop primary key; 10. Show create table <tablename>; Page 31 of 36 11. MySQL does not require that NOT NULL be defined for each column belonging to primary key. MySQL will define the column as NOT NULL itself. 12. Create table address(city varchar(20), state char(2), pin int primary key); 13. Foreign keys are defined to force a DBMS to check that no incorrect data can be entered in the tables. Answers Level 3 1. 2. 3. 4. 5. SET NULL C) Line 5, because NOT NULL constraint is not defined at table level. We can’t disable primary key but can be dropped if required with Alter command To disable: SET FOREIGN_KEY_CHECKS=0; To enable: SET FOREIGN_KEY_CHECKS=1; 6. Alter table a1 drop foreign key f1; 7. a) Domain Integrity b) Referential Integrity 8. c) REFERENCES 9. A PRIMARY KEY or UNIQUE KEY must exit on parent table 10. When the referenced and referencing tables associated with a foreign key are the same, such a table is called self-referencing table. UNIT -4 IT APPLICATION Answers of Level 1 Questions A “front-end” application is one that application users interact with directly. For example, Internet Browser or any other software application where an end user works. Ans. 2 A “back-end” application or program serves indirectly in support of the frontend services, usually by being closer to the required resource or having the capability to communicate with the required resource. For example databases like MySQL, Oracle, OOo Base, MS-Access etc. Ans. 3 E-Governance is the use of a range of modern information and communication technologies such as internet , local area network, mobiles etc. by government to improve effectiveness of their services. Ans.4 E-Learning is a delivery of learning, training or education program by electronic means Ans.5 E-business is a term used to described business run on the computer Ans.6 If Data Validation is not done then prog. May work on wrong data, therefore data validation2 is important. Ans.7 Front End : Java Back End : My SQL Ans.8 B2B, B2C, C2C C2B, B2B Ans.9 User interface is the junction between a user and a computer Program. It sets command or menus through user communicate with a program. Ans10 Textbox, text area, button, Label, checkbox, radio button, combo box, list box etc. Ans. 1 Page 32 of 36 Answers of Level 2 Questions Ans. 1 a. b. c. d. Improves Government processes Increases the efficiency and speed in a transparent manner. Simplify administrative transactions. Citizen can participate in decision making process Ans.2 i. Improved quality of information and information supply. ii. Reduction of process time. iii. Cost reduction iv. Improved service level v. Increased efficiency. Ans.3 There are various social be benefits of e-governance a. openness and transparency b. Enhanced policy effectiveness c. Increased democratic participation etc d. Increased economic competitiveness. Ans.4 It reduced overall cost, learning time reduced, increased retention and application to job. Ans.5. i. It enables students to complete training conveniently at off-hours or form home. i. Self pacing for slow and quick learners reduces stress and increased satisfaction. ii. Interactivity engage users, pushing them rather than pulling them through training etc. Ans.6 Textbox, text area, button, Label, checkbox, radio button, combo box, list box etc. Ans.7 User interface is a junction between user and a computer. it has various advantages a It provides ways to communicate b. It provide meaningful feedback when error occur and provide context sensitive user help facility. c. It provides appropriate interaction facilities for different types of system user. Ans. 8 E-learning is preferred because it provides faster learning at reduced cost, increased accessed to learning and clear accountability for all participants in the learning process. Ans. 9. i. i. Ans. 10 Use of web to find prices and reviews Use of our website for managing the information in our business. ii. Fast communication with customer, members or suppliers via email etc. b. Use of website for research and to find recent trends. There are two main issues while designing front end interfaces these are Page 33 of 36 a. How can information from the user are provided to the computer system? b. How can information from the computer system be presented to the user? The various ways of data entry are as fallows. i. Direct Manipulation ii. Menu Selection iii. Form Fill in. iv. Command Language v. Natural Language. Answers of Level 3 Questions Ans.1. Front-end means which you are going to have look and feel like jsp, swings, awt package, Backend means which is going to implement business logic for you. Ans.2. Front-end testing is basically GUI testing or GUI functional testing. Backend testing involves databases or any backend storage. It’s basically testing data while travelling from front to back end or in back end to back end only. For example, if you enter some data in front end application and it is getting stored on some database then you have to test it whether it is storing correctly you can do it by writing sql queries / scripts.Also if application is not front end (GUI) for example, you are creating some table using joining 40 different input/source tables then you have to test it. In this case you have write queries to validate source and target data between those table using sql scripts. Ans.3. It reduced overall cost, learning time reduced, increased retention and application to job. Ans4. 1. A lot of productive time of government servants and general public is saved. 2. Transparency has increased and therefore cheating cases have been reduced. Ans.5 It reduced overall cost, learning time reduced, increased retention and application to job. .Ans.6 Yes , In many ways a. Cost effective b. Time saving c. Transparency d. Simplicity in work etc Ans.7 Java interface MYSQL through JDBC. Ans.8 E-Learning offers many things as compared to normal learning like use of technology, learning on demand, participation of all etc. Ans.9 • Goods sold through e-business are generally cheaper as cost incurred in ebusiness is less compared to setting up a traditional business. • Customers can receive highly customizable service. • Even Remote area customers are reached in e-business. • Sellers have better understanding of their customers' needs as customers communicate through e-mails. Page 34 of 36 Ans.10 Textbox, option button, combo box, radio button, Label and refer case study for GUI Development Steps Page 35 of 36 Page 36 of 36