Trending ▼   ResFinder  

ICSE Notes 2017 : Computer Applications (Very Useful)

20 pages, 172 questions, 17 questions with responses, 26 total responses,    4    3
Shahid shd
St. Peter's English Medium ICSE High School, Nileshwar
+Fave Message
 Home > shahid1134 >   F Also featured on: Group Page techtoicsaf and 9 more

Instantly get Model Answers to questions on this ResPaper. Try now!
NEW ResPaper Exclusive!

Formatting page ...

Important Notes for Java [Theory] CHAPTER NO.1 OBJECT ORIENTED PROGRAMMING 1. What is OOP? Name any two OOP languages. Object Oriented Programming is an approach to standardize the program by creating portioned memory area for both data and function. It has been developed to increase the programmer s productivity and also to overcome the traditional approach of programming. In this system, the complete problem is decomposed into a number of entitles called objects.OOP languages are C++, Java, Small talk etc. 2. What are the features of OOP? It gives stress on the data items rather than function. It makes the complete program simpler by dividing in into number of objects. You can easily modify the data without any change in the function. 3. Name the Basic Elements (Principles) of OOP. Object, Classes, Data Abstraction, Encapsulation, Data Hiding, Inheritance, Polymorphism and Dynamic Binding. 4. Define the following with examples each. i) Object: It is a unique entity, which contains data and functions (characteristics and behavior) together in an OOP language. Eg. Book:- Characteristics Chapter, pages, topics. Behaviours Used to read, prepare notes. ii) Class: Class is a set of similar objects. Each object of a class possesses same attributes and common behavior defined within the same class. Eg. If we define a class Car , then different types of cars like Maruti, Santro, Indica, Nano are referred as objects under that category. iii) Data Abstraction: Abstraction refers to an act of representing essential features without including background details. In OOP, abstraction is the absolute property of a class. The class encapsulates the data items and the functions to promote abstraction. Eg. If we create a object Employee from a class name Salary and let name, designation and basic_pay are the data members and Gross( ), PF( ) and Net ( ) are the methods, then the object Employee allows to access only essential features i.e. the methods, which in turn manage the data internally to perform the tasks. iv) Inheritance: It is the process by which objects of one class can link and share some common properties of the object from another class. Eg. Circle is a part of the class two-dimensional, which is in turn a part of the class Mensuration. v) Polymorphism: It is the process of using a function for more than one purpose. It allows the use of different internal structure of the object by keeping the same external interface. 1 | Page Important Notes for Java [Theory] Eg. If you develop a function to perform the addition of two numbers, the same function will produce the concatenated string, if string arguments are passed to the function. vi) Dynamic Binding: It is the process to link the function call with function signature at run-time. vii) Encapsulation: The system of wrapping data and function into a single unit (called class) is known as Encapsulation. Eg. A remote control of a TV set(a real world object) is used for operating all the function of that particular TV, but can t be used for operating various functions of another TV. 5. Explain Data Hiding. The insulation of data that does not allow it to be accessed directly outside the class premises, although they are available in the same program, is known as Data Hiding . 6. A class is termed as Object Factory, explain. Class is a prototype (model) of an object. Each object belonging to a specific class possesses the data and methods defined within the class. It produces objects of similar type. Hence, a class is termed as object factory. 7. Class is a user defined data type.( OR ) Why is class known as composite data type. Comment. Java language uses some pre-defined data types viz. int, float, char. These data types are also known as Composite Data Types , which provide some preliminary facilities in java programming. Similarly, a user may create data type and declare certain characteristics and behavior within it. This can be done by using a class. This is the reason why a class is referred as user defined data type. 8. Why an object is called an instance of a class? As the object encapsulates the state and behavior present inside the class thereby we can say object is an instance of class. 9. How will you consider Mobile Phone a real world object? Anything which has characteristics and behavior can be called as an object. Characteristics of mobile phone are it is portable, small in size etc. Behavior is used to talk with friends anywhere in the world. That is why mobile phone is a real world object. 10. What does the following mean? / Steps to create an object of a class. Flower rose = new Flower ( ); This statement will create an object name rose, of Flower class. The new operator allocates memory and calls the default constructor of Flower class. 11. State the Difference between Class and Object Class Object It is a representation of only an It is a real and unique entity having some abstraction. characteristic and behavior. 2 | Page Important Notes for Java [Theory] It is an object producer and hence called a It is created with the use of new operator. blue print for a set of objects It is known as Object Factory It is known as an Instance of Class 12. Why class is called an Abstract data type? In OOP the class encapsulates the data items and the functions. The data members are accessed only through the related functions. Since, a class uses the property of abstraction; it is also called as abstract data type. CHAPTER NO.2 HISTORY AND DEVELOPMENT OF JAVA 1. State the different types of Java programming. Stand Alone System (Java Application) and Internet Applets (Java applets) are the two types of Java programming. 2. State the basic features of Java. Java is an OOP language. Java programs are both compiled and interpreted. Java programs are platform independent. It can be access data from a local system as well as from net. It is case sensitive language. 3. Define the following terms i) Compiler: The software by which the conversion of the high level instructions to machine level language is done all at once and all the errors are listed together, it is known as compiler. This is a much faster process but sometimes it become difficult to debug all the errors together. ii) Interpreter: The software, by which the conversion of the high level instruction is performed line by line to machine level language, is known as an Interpreter. If an error is found on any line, the execution stops till it is corrected. iii) Byte Code: The program(HLL) written in Java is compiled for conversion to an intermediate code called Byte Code. This code is independent of the machine on which the program is to run. This makes a Java program highly portable as its byte code can easily be transferred from one system to another. iv) JVM : When the Byte code is run on any system, an interpreter, known as Java Virtual Machine (JVM) is needed which translates the byte code to machine code. Java machine code varies for different platforms like Windows, UNIX etc. Thus, Java interpreter converts byte code to the machine code accordingly. JVM acts as a virtual processor. That is why it is called as Java Virtual Machine. 4. A Java program uses a Compiler as well as an Interpreter. Explain. The program(HLL) written in Java is compiled for conversion to an intermediate code called Byte Code. This code is independent of the machine on which the program is to run. When the Byte code is run on any system, an interpreter, known as Java Virtual Machine (JVM) is needed which translates the byte code to machine code. Thus a Java program uses a compiler and interpreter. 3 | Page Important Notes for Java [Theory] 5. Explain the significance of the following Java library packages. i) java.lang : to support classes containing String, character, Math, Integer etc. (called by DEFAULT) ii) java.io : to support classes to deal with input and output statements. iii) java.applet : to support classes to generate applet. iv) java.net : to support classes for network related operation and URL v) java.awt : to support abstract window took kit and to manage GUI vi) java.txt : for supporting text elements such as dates, times, currency. vii) java.math : to support mathematical functions (square roots)int and deci. 6. What are Reserved words (key words). Give examples. They are the words preserved with the system and they cannot be applied as a variable name in any program. Eg. int, float, double, if, else, for, switch, break etc. 7. Name the different styles of expressing a comment in Java programming. (OR) State the significance of comment in Java Programming. Sometimes it become difficult for a user to understand the logic applied in a program particularly when any other person has developed it. In such cases, the programmer keeps mentioning the purpose and action being taken in different steps. This can be made possibly only by applying comment in the program. There are three ways to give a comment in programming. i) // : used for single line comment ii) /* comments to be written */ : used for multi line comment iii) /** documenting comment */ : used for brief documents. 8. Why JVM is termed as a machine although it is software? JVM acts as a virtual processor, which processes the byte code to machine code instruction for various platforms. JVM acts as if it is a machine that is why JVM termed as a machine although it is software. 9. Explain the significance of the following terms. i) public : It is used to declare that the file access has no restriction. ii) static : It is a keyword that instructs the complier that the following functions should run before anything else in the program. iii) void : It indicates that the following function will not return any value. iv) class : It is keyword to declare a class. The keyword is followed by the class name. CHAPTER NO.3 CONCEPT OF DATA TYPES IN JAVA 1. Explain Tokens and its types. Each individual character used in a Java program is termed as token. It is the fundamental unit of a Java program. The various types of tokens available in Java are Literals, Identifiers, Assignments, Punctuators, Seperators and Operators. 4 | Page Important Notes for Java [Theory] 2. Define (Explain) the following i) Literals (Constant): Literals are the constants in Java program. When you write a program in Java, you may come across some quantities which remain fixed throughout the discussion of the program. Such quantities are termed as Literals / Constants. Eg. String Literals, Real literals, Character literals, Boolean literals, Integer Literals. ii) Punctuators : They are the punctuation signs used as special characters in Java. Eg. ? (question mark) ; (semi colon) . (dot) etc. iii) Separators : They are special character in Java, which are used to separate the variables or the characters. Eg. Braces (, ) Curly braces {, } Square braces [, ] etc. iv) Operators : They are basically the symbol or tokens to perform arithmetical or logical operations to yield meaningful result. They are of three types : Arithmetical Operators: +, - , /, * etc. Relational Operators: <, >, ==, !=, <=, >= etc. Logical Operators : &&, || and ! etc. v) Static initialization : This process uses direct assignment of a variable with defined constant. The variable is initialized during its declaration (i.e. before the actual use in the programming logic) e.g. int a=5; double d=5.3; vi) Dynamic initialization : When a variable gets initialized at run time i.e., during the execution of program logic is termed as Dynamic Initialization. E.g., int a,b,c; c=a+b; vii) Pure Arithmetic Expression : An arithmetic expression which, contains same type of data items (variables or constants) is called Pure Arithmetic expression. E.g. int a,b,c; c=a+b*8-a; viii) Mixed Expression: An expression, which includes different types of variable or values to yield a result, is known as Mixed expression. E.g. int a, float b, double d; double x = a+ b*d; ix) Implicit type conversion : In mixed expression, the data type of the result gets converted automatically into its higher type without intervention of the user. This system of type conversion is known as Implicit type conversion or coercion. Hierarchy of data type is as follows from lower to higher byte char short int long float double. x) Explicit type conversion : When the data type gets converted to another type after the user intervention, the type conversion is known as explicit type conversion. This type of conversion is also called forced conversion or type casting. E.g. int a,b; float x=(float)(a+b); 3. Explain the significance of Escape Sequences with examples. There are some non-graphic characters, which are used as commands to direct the cursor while printing. These characters are frequently used in Java programming 5 | Page Important Notes for Java [Theory] called escape sequences. An escape sequence character begins with a blackslash(\) and it followed by one or more character. Escape Sequences Non Graphic Character \t Horizontal Tab \v Vertical Tab \\ Backslash \ Single Quote \ Double Quote \f Formfeed(Clear Screen) \n New line feed. 4. Explain Primitive and Non-Primitive Data types. The data types, which are independent of any other type, are known as Primitive data types. These types are also called Basic Data Types. E.g., byte, int, long, float, double etc. Primitive data types are pre-defined or built-in data types because the system developers of Java have defined them. Non-Primitive are basically defined as derived data types. They are directly or indirectly dependent on primitive data types. The method of storing non-primitive type data is different from primitive type data. They store the data values with reference to the addresses or locations. So, they are also called Reference Data type e.g. classes, arrays etc. CHAPTER NO.4 OPERATORS AND EXPRESSIONS IN JAVA 1. What are operators? Explain its types. An operator is basically a symbol or token, which performs arithmetical or logical operations and gives meaningful result. (The values, which are involved in the operation, are termed as operands) Basically there are three types of operators. i) Arithmetical operators: They are used to perform arithmetical calculations in a program. E.g. +,-,*,/ and % etc. ii) Relational operators: They are used to show the relationship among the operands. They compare the values of the variables and result in terms of true or false. E.g. <, >, <=, >=, ==, and !=. iii) Logical operators: They are used to apply logical condition is a decision control statements. E.g. && (AND), ||(OR) and !(NOT) 2. Define (Explain) the following terms i) Unary Operator: An arithmetical operator, which is applied with a single operand, is known as Unary Operators. E.g. +, -, ++, --. ii) Binary Operator: An arithmetical operator, which deals with two operands, is known as Binary Arithmetic operators. E.g. +, -, *, / and %. iii) Ternary Operator: It deals with three operands. It is also called conditional assignment statement because the value assigned to a variable depends upon a logical expression. Syntax- variable=(test expression)?Expression1:Expression2 6 | Page Important Notes for Java [Theory] the variable contains the result of expressio1 if the test condition is true, otherwise expression2. iv) Shorthand operations: Java allows the use of shorthand binary operations i.e., an expression can be written in short form eg. A=a+b can be written as a+=b, it can be formed only when a variable is used as an accumulator in the expression i.e., same variable is to be used after and before the assignment sign. 3. Distinguish between i) Increment and Decrement operators Increment Operators Decrement Operators Increment Operator (++) increases Decrement Operator (--) decreases the value of an operand by one. the value of operand by one. E.g. x=x+1 by applying increment E.g p=p-1 by applying decrement operator it can be written as x++ or operator it can be written as p- - or ++x. --p ii) Postfix and Prefix increment Postfix increment This operator is used after an operand whose value is to be increased by 1. It works on the principle CHANGE AFTER THE ACTION E.g. p=5; p=p++*4 Result is 20 iii) Postfix and Prefix decrement Postfix decrement This operator is used after an operand whose value is to be decreased by 1. It works on the principle CHANGE AFTER THE ACTION E.g. p=5; p=p--*4 Result is 20 iv) / and % / is a division operator whereas % is a modulus Prefix increment This operator is applied before the operant whose value is to be increased by 1. It works on the principle CHANGE BEFORE THE ACTION E.g. p=5; p=++p*4 Result is 24 Prefix decrement This operator is applied before the operant whose value is to be decreased by 1. It works on the principle CHANGE BEFORE THE ACTION E.g. p=5; p=--p*4 Result is 16 operator int a=5,b=2 then a/b will return 2 whereas a%b will return 1 v) (p!=q) and !(p==q) (p!=q) in this case the computer is checking whether the value of p is not equal to q. !(p==q) in this case the computer will reverse the logic of the output (p==q), if it is true it will become false and vice versa. CHAPTER NO.5 GENERAL PROGRAMMING AND DECISION MAKING IN JAVA 1. What is compound statement? Multiple statements written within braces { }, are known as compound statements. 7 | Page Important Notes for Java [Theory] 2. What are packages? How do we include it in a program? Package is a collection of classes to perform various functions. Every package has a name and it can be included with the program by using the keyword import. 3. All important Mathematical functions NAME Math.sqrt( ) DESCRIPTION RETURN TYPE To find the square root of a Double positive number EXAMPLE a=Math.sqrt(4) Output: 2.0 Math.min( ) To find the minimum of the int or double b=Math.min(5.3,4.8) two given arguments depends on Output:4.8 given argument Math.max( ) To find the maximum of the int or double c=Math.max(5,4) two given arguments depends on Output:5 given argument Math.pow( ) To find power raised to a double specified base D=Math.pow(2,3) To find natural logarithmic double value of a given argument. E=Math.log(6.25) Math.log( ) Output: 8.0 Output=1.8325 Math.abs( ) To find absolute value. Math.round( ) To find value in rounded Int form(same rule as we use in math for rounding) G=Math.round(6.82f) It returns a number down to double the nearest integer.(watch closely for negative numbers) H=Math.floor(6.9); Math.floor( ) Same as the int f=Math.abs(-9); input argument Output: 9 Output=7 here f is for float data type. Output=6 H=Math.floor(-6.25) Output =-7 Math.ceil( ) Math.sin( ) Math.cos( ) Math.tan( ) Math.asin( ) 8 | Page It return a number to the next double higher integer. (Watch out the difference between floor and ceil with the help of the given examples) I=Math.ceil(6.9) To find the sin, cos, and tan double values of a given angle in radian as an argument J=Math.sin(x) Used J=Math.asin(x) to find the angle double Output =7 I=Math.ceil(-6.25) Output=-6 Here x is the angle provided in radian. Important Notes for Java [Theory] Math.acos( ) Math.atan( ) Math.exp( ) corresponding to the given value in sin, cos and tan respectively. It is used to find exponential value i.e. the double ex. where e is the number (approximately 2.718281828) it is similar to b=Math.pow(2.718281828,6.25); Math.rint( ) Math.random( ) K=Math.exp(6.25) Output: 518.0128 It return a truncated value of double the number(integer part by removing fraction) and rounding L=Math.rint(6.25) To return a random number double between 0 and 1(Check for all the possible modification in the book) M=Math.radom( ) Output =6.0 4. Name the different ways to get the data value within a Java program. 1) By assigning the value. 2) By using BlueJ system 3) By using Input Stream 4) By using scanner class 5) By using command line argument. 5. Explain the significance of Buffer . Processor is the fastest device in computer. Other peripheral devices are comparatively slower then processor. Due to speed difference it becomes difficult to have data communication between processor and peripheral devices. Hence a high speed memory is applied between I/O devices and processor used as a bridge to synchronize their speed. This high speed temporary storage (cache memory) is termed as Buffer. 6. Explain the purpose of default in a switch statement. Each case ends with a break statement, which acts as a terminator and the control comes out of the block. The switch case statement has a default statement, and it is executed only when the switch value doesn t match with the case. It doesn t require any usage of break as it is the last segment of the switch case structure. 7. What do you understand by Fall through ? In a program where multiple cases are available, the control needs to execute a specific case block for a given switch value. Under these circumstances, if break statement is not applied at the end of a case then the control enters into the next case statement for the execution. This unusual execution of more than one case at a time is termed as fall through. 8. State the difference between if else and switch case. if else switch case It results in a Boolean type value. 9 | Page It result in int/char type value. Important Notes for Java [Theory] For true/false condition, either of two Specific case is operated for a given blocks are operated. switch value. It can perform tasks on a relational or It can only perform test for equality. logical expression No default operation A default case is used. 9. State the difference between testing and debugging Testing Debugging Testing is a process in which a program is Debugging is a process in which the validated errors in the program are removed Testing is complete when all desired Debugging is finished when there are no verification against specification have errors and the program is ready for been performed. execution. 1. 2. 3. 10. Explain the types of error with examples. In general there are three types of errors that occur in a computer program. i) Syntax error: These errors result when the rules or the grammar of the programming language are not followed. Such errors typically involve punctuation, incorrect word sequence, undefined terms or misuse of terms. E.g. c=(a+b/2) has a syntax error because (;) is missing. ii) Logical error: It is an error in planning the program s logic. The computer actually does not know that an error has been made. It follows the instructions and executes the results, but the output may be wrong. The problem is that the logic being followed does not produce the desired result. iii) Run time error: In a program there may be some errors other than syntax and logical error which may come in the way of execution, known as run time error. These errors may occur due to dividing a number by zero or to find the square root of a negative number etc. CHAPTER NO.6 ITERATION THROUGH LOOPS What do you understand by a loop? What is its significance? Loop is Java programming is a set of instruction which will get repeatedly executed as many times we want. Loop helps to solve the real life complex problems, if we want to perform a particular task for the specified number of times, we can do it very easily with the help of loop statement. What are the different ways to generate a loop? Loop can be generated in three ways 1) Using the keyword for 2) using the keyword while 3) by using the keyword do and while . Write the general format of : i) for loop for(initialization of counter ; testing of counter with condition ; increment/decrement of counter ) { 10 | P a g e Important Notes for Java [Theory] 4. 5. 6. Multiple statements; } ii) while loop initialization of counter; while(testing of counter with condition) { Multiple statements; Increment/decrement of counter; } iii) do while loop do { Multiple statements; } while(testing with condition); Explain the use of break statement with example. (Also called as Jump statement) A break statement is used for unusual termination of a block. As soon as you apply a break statement, the control exits from the block.(A set of statements under curly braces). while(condition) { Multiple statements; if(condition is true) break; } Explain the use of continue statement with example (Also called as Jump statement) The statement continue is just opposite of break statement. As soon as the continue statement is executed in a loop, the control skips rest of the statements for that value and resumes for the next iteration. while(condition) { Multiple statements; if(condition is true) continue; statements;} Write the difference between while loop and do-while loop (entry controlled loop and exit controlled loop) While loop Do-while loop The while loop will not executed at all if The do-while loop will continue at least the condition is not satisfied once. 11 | P a g e Important Notes for Java [Theory] The while loop checks the condition first and then execution begins. It has a check before the entry in the loop hence it is called as entry controlled loop. The do-while checks the condition after executing the loop once. It has a check after the loop is over for the first time hence it is called as exit controlled loop. Similarity between them is that both are looping statements. 7. What do you mean by infinite loop? Infinite loop is a loop in which the test condition always remains true and the loop repeats infinitely. In it the increment/decrement counter does not exists, so the condition will never be true. 8. Explain user controlled loop Sometime in a program we do require a loop, which make iteration based on the needs of the users. Such looping structure is termed as user controlled loop. E.g String m= yes ; while(m.equals( yes )) { Multiple statements; System.out.println( Want to continue . If yes press yes else no? ); m=in.readLine( ); } This loop shown above will keep repeating as long as the user enter yes for continue question. CHAPTER NO.7 USING LIBRARY CLASSES 1. What are library classes? Give examples. The classes which are already built in java are called library classes. These classes are grouped together and stored in a package. E.g. java.io contains input/output functions. 2. Explain about input/output operations in Java. Java language uses the function read ( ) (E.g. a= System.in.read( ) )to accept a character from the keyboard and print ( ) or println ( ) (E.g. System.out.print(x) ) to display the result on the screen. Here System.in.read( ) is an input stream belonging to the system class, which is, in turn an object of input steam class available in java.io package. 3. Explain the different types of I/O streams used in Java programming. There are 3 types of I/O streams available with Java system. System.in, System.out and System.err The stream System.in is an input stream related with keyboard, System.out and System.err are output streams related with VDU. 4. What do you mean by exception handling? How it can be done in Java system? Sometimes, during java programming, we come across a situation that it is difficult to say that our code segment is error free. Such unexpected situation may appear due to 12 | P a g e Important Notes for Java [Theory] 5. 6. 7. 8. improper use of input resources or overflow situation. These situations are termed as Exception and to overcome such situation is known as Exception Handling. i) Try and catch keyword plays an important role in exception handling in a java program. (try-catch method) ii) If you want that the system is to be reported for an error then you can apply throws keyword. (exception handling with throws keyword) e.g public void getdata( ) throws IOException What is a wrapper class? Give example. Wrapper classes are those classes which wraps predefined basic data type. Some examples of wrapper classes are integer, double, character etc. These classes extends the feature of basic data types. Define Static Data member: A static data member is an instant variable which is global in the class and used commonly by all the objects of that class type. Define Static Member method: A static member method is a member method which uses only static data member or static instant variables. What are packages in Java. Package is a group of classes, which can be imported to a program so that the user may exercise the implicit facility available in it. A package in java program can be included by using import command. E.g. import java.util.*; Some basic packages which can be imported for various fundamental operations are java.io, java.util, java.awt, java.net. CHAPTER NO.8 STRING MANIPULATION IN JAVA ALL IMPORTANT CHARACTER FUNCTIONS NAME Character.isLetter( ) DESCRIPTION To check whether a given argument is an alphabet or not. Character.isDigit( ) To check whether a given argument is a digit or not. Character.isLetterOrDigit() To check whether a given argument is a letter or digit. Character.isWhitespace( ) Check for given 13 | P a g e RETURN TYPE EXAMPLE boolean C=Character.isLetter( a ); Output=true boolean C=Character.isDigit( a ); Output=false boolean C=Character.isLetterOrDigit( % ) Output = false boolean C=Character.isWhitespace( ) Important Notes for Java [Theory] argument is a space or not. Character.isUpperCase( ) Check for argument is upper case letter or not Character.isLowerCase( ) Check for argument is lower case letter or not Character.toUpperCase( ) Convert the argument to upper case Character.toLowerCase( ) Convert the argument to lower case ALL IMPORTANT STRING FUNCTIONS NAME length( ) charAt( ) indexOf( ) lastIndexOf( ) substring ( ) toLowerCase( ) toUpperCase( ) replace( ) concat( ) 14 | P a g e DESCRIPTION Output =true boolean C=Character.isUpperCase( a ) Output= false boolean C=Character.isLowerCase( a ) Output= true Char B=Character.toUpperCase( a ) Output =A Char B=Character.toLowerCase( S ) Output =s RETURN TYPE EXAMPLE Find the length of the string Returns the character for the given position no. Returns the position no. of the string Returns the index of last occurrence of a character Returns the extracted part of the string Int Converts the string to lower case Converts the string to upper case Replace the char by another char or string by another sting. String To join two string String Char Int Int String String String A= Wisdom .length( ) Output =6 C= Wisdom .charAt(3); Output=d int a= Wisdom .indexOf( d ); Output= 3 int a= Malayalam .lastIndexOf( a ) output = 7 A= Wisdom .substring(3) Output=dom A= Wisdom .substring(2,5) Output=sdo A= WISDOM .toLowerCase( ) Output=wisdom A= wisdom .toLowerCase( ) Output=WISDOM A= wisdom .replace( s , x ) Output=wixdom A= all the best .replace( best , worst ); Output=all the worst A= wisdom .concat( high ); Output=wisdomhigh Important Notes for Java [Theory] equals( ) Compare two string Boolean Z= wisdom .equals( high ) for equality (same) Output=false equalsIgnoreCase() Compare two string Boolean Z= for equality wisdom .equalsIgnoreCase( high ) (same)with ignoring Output=false case compateTo( ) Check for equality of Int A= TOY .compareTo( CAR ); two strings, and also Output=17 (check with different check whether a inputs) string is bigger, smaller than the other. trim( ) Removes blanks String A= computer application .trim() from either side Output=computer application endsWith( ) Check whether given Boolean Z= car is a toy .endsWith( car ); string has specified Output=false suffix or not startsWith( ) Check whether given Boolean Z= car is a toy .startsWith( car ); string has specified Output=true prefix or not CHAPTER NO.9 ARRAYS 1. What is an array? (Dimensional Array) An array is a structured created in the memory to represent a number of same type of data(int/double/string etc) with the help of single variable. An array is also called as subscripted variable. 2. Explain the difference between linear search and binary search Linear search Binary search It works for both sorted and unsorted It works only for sorted data items. data. The search begins at the start of an array An array is divided into two halves and (i.e. from 0th position of an array) then the search stats either in the first half or the second half 3. Explain the difference between selection sort and bubble sort Bubble sort Selection sort In this method the array is In this method the successive rounds sequentially scanned several times are executed to select the element in and during each iteration the pairs of some order and place them into their consecutive elements are compared positions. and interchanged, if necessary, to bring them into specific order. 4. Explain the difference between length and length( ). Length length( ) It is a variable used with array which It is a function used with strings which 15 | P a g e Important Notes for Java [Theory] 5. 1. 2. 3. 4. 5. 1. 2. 3. 4. 5. returns the number of elements present returns the number of character present in it. in it. Explain the difference between ordinary variable and array (subscripted) variable Ordinary variable Array variable It has a capacity to store only 1 value at a It has a capacity to store multiple values time. at a time. It is not accompanied by [ ] It is always accompanied by [ ] CHAPTER NO.10 BASIC INPUT/OUTPUT (Scanner and Printer Classes) Name the package in which the scanner class is defined. It is defined within a package java.util. Name the package which can be imported to allow the use of scanner class. import java.util.Scanner; Write the syntax to create the scanner object. Scanner sc= new Scanner(System.in); Write a syntax to create the PrintWriter object. PrintWriter so=new PrintWriter(System.out,true); In what way the following data can be read from scanner object? Integer type : int p=sc.nextInt( ); Float type : float f=sc.nextFloat( ); Double type : double d=sc.nextDouble( ); String type : String p=sc.nextLine( ); where the scanner object is Scanner sc= new Scanner(System.in); CHAPTER NO.11 FUNCTIONS/METHODS Define Function/Method. A program module (a part of the program) used simultaneously at different instances in a program to perform specific task, is known as Method or Function What is mean by invoking a function? A process of using a method in a program is referred as calling a method or invoking a function. Explain Formal Parameter The parameter, which are described in the function definition (receive the value) are called as Formal Parameter. E.g. int Add (int m, int n) here int the return type of the function name Add and (int m, int n) are formal parameter. Explain Actual Parameter The parameter described in the caller definition (the values passed to the method) are known as Actual Parameter . E.g. p=ob.Add(a,b); here function Add is being called by ob.Add and (a,b) are actual parameter. Explain Pass by Value It is the process of passing a copy of actual parameter to the formal parameter. Any change made in the formal parameter does not reflect on the actual parameter. All 16 | P a g e Important Notes for Java [Theory] primitive data type such as int , float, char, double are by default passed to the function by using pass by value system. 6. Explain Pass by Reference It is the process of passing a reference (address) of the actual parameter to the formal parameter and any change made in the formal parameter will be reflected on the actual parameter. In java the non-primitive data (arrays, objects) to be passed to the method as pass by reference. 7. Explain Pure Function A function, which returns a value to its caller module, is called as Pure Function . It is also called accesser method, as it doesn t change the state of an object. 8. Explain Impure Function An impure function may not return a value. It basically changes the state of an object during call. It is also called as Mutator. 9. Explain Function Overloading Java language facilitates designing a number of functions with the same function names. However their parametric types must be different. Such functions are called overloaded functions and the system is said to be function overloading. Through function overloading java implements Polymorphism. 10. Explain Static Binding When the programmer uses the concept of function overloading the compiler during compilation finds the function by matching the types and number of arguments to insure which of the function will be called. This system is known as Early binding or static binding. 11. What are the two ways of invoking a function? They are 1. Call by value 2. Call by reference. 12. What are the advantages of defining a method/function in a program? Method/Function is a set of statements referred by a single name. Its advantages are i) Reusability ii) To cope up with complexities. 13. Explain as how you define a method/Explain function prototype. The general form of defining a method is as follows <Access-specifies><Return Type><Function Name>(Parameter list) A function prototype is the first line of a function definition. With reference to the above form the function prototype is : public int Add(int a, inb b) 14. What is the role of keyword void in declaring a function? Void specifies that the function will return null value. The function which explicitly does not return a value has a return type void. 15. Write the features of return statement. i) It is applied at the end of a method, from where it terminates. ii) No statement in the method can be executed after return statement. iii) It can return a single value from a method to its caller. 17 | P a g e Important Notes for Java [Theory] CHAPTER NO.12 CLASS AS A USER DEFINED TYPE 1. Write the syntax of creating object of a class. Sum ob=new Sum ( ); Here Sum is a class name ob is the object (you can use any name here) new is the keyword used for allocating dynamic memory of an object Sum ( ) is a constructor 2. Write the difference between User defined data type and Primitive data type User-defined data type Primitive data type These data types are created by the users. These are built in data types, which are provided by the system. They are available in accordance to their These data types are available with the visibility modes throughout the program. system. 3. Which OOP concept is implemented by using class? Data Hiding 4. Explain the contents of a class. The content of a class is divided into two. i) External wrapper ii) Internal content External wrapper is the class declaration enclosing inner part within a pair of curly brackets. E.g. class calculate { // inner part of the class } Internal content of a class contains the following Instant variables, Constructor and Member method 5. Explain Access Specifier Access specifiers are also known as visibility modes. They are categorized as follows i)Public ii)Private iii)Protected Public: The class members(variable or method) specified as public can be used even outside the visibility of a class. Private: The data members(Instant variables or member methods) which are specified as private can be used only within the scope of a class. These members are not accessed outside the class. Protected : The protected members are used in the class as private members which can only be applied within the class but can be applied to another class during inheritance. 6. Explain the significance of new operator. 18 | P a g e Important Notes for Java [Theory] New operator is used to create a class object or an array. It allocates memory and returns the reference of memory at run time. 7. Differentiate between static and non static data member. Static data member Non-static data member Static members are the members which Non-static members are the members maintain a single copy for the whole class which maintain a separate copy for each and are shared by all the objects of that and every individual object of that class. class. They are also known as class variables They are also known as instant variables Imp:- the keyword that differentiate between instant variable and class variable is static. CHAPTER NO.13 CONSTRUCTOR 1. What is constructor, name its types. A constructor is a member function with a name same as that of all the class name and is used to initialize the instant variable of the objects. Constructors are of three types. i)Default constructor ii) Parameterized constructor iii)Copy constructor 2. Mention the features of Constructor. i) Constructor is defined with the same name as a class name. ii) Constructor is automatically called while creating an object. iii) Constructor needs no return type. iv) Constructor is always public. v) Constructor is overloaded automatically vi) Constructor is only created to initialize the data members/instant variables. 3. Explain Default constructor. A constructor which initializes instant variable of an object with definite values readily defined is known as default constructor. 4. Explain Parameterized constructor. A parameterized constructor is a member function with same name as the class name which is used to initialize the object variables by passing parametric values at the time of its creation. 5. Explain Constructor Overloading A process to use a number of constructors with the same name but different types of parameter list is known as constructor overloading. E.g. class constructor { int a,b; constructor ( ) { a=0; 19 | P a g e Important Notes for Java [Theory] 6. 7. 8. 9. b=0; } constructor(int x, int y) { a=x; b=y; } } Differentiate between constructor and method Constructor Function/Method Constructor has the name same as that Function has name other that class name. of the class name Constructor doesn t require to be called Method is called from the main class. from the main class It does not return any value It may or may not return any value. Define Encapsulation It is the process of wrapping of data and function together as a unit and this can be made possible by using class member private. Define Inheritance It is a process according to which some properties of a class are shared by another class or classes is known as inheritance. Explain Base class and Derived class A base class is a class which is inherited to another class. A derived class is one which inherits a base class. 20 | P a g e

Formatting page ...

Top Contributors
to this ResPaper
(answers/comments)


Siddhant Joshi

(11)

Onkar Borade

(4)

Ansh Gupta

(4)

Hacker

(3)

Formatting page ...

Formatting page ...

Formatting page ...

Formatting page ...

Formatting page ...

Formatting page ...

Formatting page ...

Formatting page ...

Formatting page ...

Formatting page ...

Formatting page ...

Formatting page ...

Formatting page ...

Formatting page ...

Formatting page ...

Formatting page ...

Formatting page ...

Formatting page ...

 

  Print intermediate debugging step

Show debugging info


 

 

© 2010 - 2025 ResPaper. Terms of ServiceContact Us Advertise with us

 

shahid1134 chat