Computer Applications - Notes
Computer Applications - Notes
float double
It is single precision 32bit It is double precision 64 bit
Default value 0.0f Default value 0.0d
If..else switch
It can perform all relational It can perform only ==
comparisons comparison
It works with any data type It works with byte, short, char, int
primitive data type
It executes a certain section of It can have a number of possible
code only if a particular test execution paths
evaluates to true
== equals()
It is used to check the equality This function checks the equality
between primitive datatype. between the strings.
/ %
It is a division operator It is modulus operator
It gives quotient It gives the remainder
Constructor Function
It has no return type, not even void It has void or a valid return data
type.
It has 2 types: default and It has 2 types: call by value and
parameterized call by reference.
It is invoked automatically when It must be called by using object
object of class is created. of the class or directly.
It is a function having same name It is always defined by any name
as class name. except keyword.
next() nextLine()
Accept a string without any space. Accepts a string with the space.
It terminates the input of
characters when a space is met.
Searching Sorting
To find an element in an array is To arrange the elements in an
called searching. order is called sorting.
isUpperCase() toUpperCase()
Return type is boolean Return type is char
Checks whether a given character Converts the character to its
is an uppercase letter or not upper case.
While do..while
Entry controlled loop Exit controlled loop
Minimum repetition is 0 Minimum repetition is 1
If condition is false in the Loop will execute at least once
beginning , loop never executes. even if the condition is false.
length length()
It is used to find the length of an It is used to find the length of a
array. string.
Eg. int a[] = new int[10]; Eg. String s = “ABC”;
int l = a.length; int l = s.length();
= ==
It is an assignment operator It is a relational operator
It is used to assign a value to a It is used to check the equality
variable between primitive datatype.
SOP() SOPln()
After printing , the cursor remains After printing cursor goes to the
on the same line. next line.
Eg. SOP(“India”); Eg. SOPln(“India”);
SOP(“ is my country”); SOPln(“ is my country”);
Output: India is my country Output: India
is my country
Prefix Postfix
When increment or decrement When increment or decrement
operators are applied before the operators are applied after the
operand , they are called prefix operand , they are called postfix
operators. operators.
The value of the variable changes The value of the variable changes
before the operation takes place. after the operation takes place.
It works on the principle of It works on the principle of
“change before action” “change after action”
nextInt() hasNextInt()
Return type is int Return type is boolean
It receives the next token as an It checks whether the next token in
integer from the scanner object the scanner object can be
interpreted as an int value
Boolean boolean
It is a wrapper class of the It is a primitive datatype
primitive datatype boolean
Testing Debugging
It is a process in which a program is It is a process in which the errors
validated. in the program are removed.
It is complete when all desired It is finished when there are no
verifications against specifications errors and the program is ready
have been performed. for execution.
break Continue
It is used for unusual termination It is opposite of break. As soon as
of loop. As soon as break is continue is executed , the control
encountered, the control exits skips the rest of the statements
from the loop. and goes for the next iteration.
throw throws
It is applied within a function It is used along with function
signature
It is used to handle a specific It maybe used to eliminate
exception multiple exceptions
It is used for explicit elimination of It is used to declare an exception
an exception
Private Protected
Private elements are not shared They can be applied to the
by another class during derived class at the time of
inheritance. inheritance.
They are not accessed outside the They are used in the class as
class. private members which can be
applied within the class.
Object Class
It is an instance of a class. It is a blueprint or a template from
which objects are created.
It is created through new It is declared using keyword class.
keyword. E.g. Xyz obj =new Xyz(); E.g. class Xyz{ }
It is real and unique entity having It is a representation of an
some characteristics and abstraction only.
behaviours.
equals() compareTo()
Return datatype is boolean Return datatype is int
It only compares 2 strings and It also gives whether the first string
gives whether they are equal or is greater or smaller than the
not second one.
Define Encapsulation?
They are the words that convey a special meaning to the language
compiler. These are reserved for special purpose and must not be
used as normal identifiers. Ex. Public, int, else
What is inheritance?
A for statement which doesn’t include any statement in the body of the
loop is called null loop or empty loop.
It is the process of defining functions with the same name but with
different number and types of parameters.
They are used in the class as private members which can only be used
within the class but can be applied to another class during
inheritance.
Xyz()
{ a=0;}
Xyz(int s)
{ a =s;}
When a sub class inherits from multiple base classes, it is called multiple
inheritance.
A target which inherits a base class can be in turn used as a base for
another target. Such system is called Multilevel inheritance.
When more than one type of Inheritance systems are used together, it is
called Hybrid Inheritance.
It is the process that links the function call with function signature at run-
time.
It is the first line of the function which contains its access specifier, return
type, function name, and list of parameters(number, type and order).
e.g. public int Add(int m, int n)
It is the method name along with the number, type and order of its
parameters. E.g. factorial(int)
Linking a function with its caller program at the time of creating program
logic is called static binding.
It is the explicit conversion of one datatype into another using the typecast
operator()
What is an exception ?
It is an event that occurs during the execution of a program that
disrupts the normal flow of instructions.
Library classes are the predefined classes which are a part of Java API. E.g.
String, Scanner
What is an array ?
What is a literal ?
It is a constant data item. There are different literals like ‘A’ which is
character literal, false which is Boolean literal etc.
Define variable ?
It is a named memory location , which holds a data value of a particular
data type. Eg double p;
Explain System.exit(0)?
This function is used when we want to terminate the execution at any
point of the program. As soon as the function is invoked, it terminates
the execution ignoring the rest of the statements of the program.
What is autoboxing ?
The automatic conversion of primitive datatype into an object of its
equivalent wrapper class is known as autoboxing.
e.g Integer I = new Integer(26);
What is Unboxing ?
Unboxing is the system of converting an object of wrapper class into
primitive data type.
int y = I;
The cell number of the array used within square bracket along with array
variable is said to be subscript of an array.
It refers to assigning the values to the array at the time of its declaration.
They have the same name as that of the class name. They are executed
when an object is created.
It reduces the length of the program. It takes less memory space for
storage of program. Debugging is easier. It enhances reusability of
code.
1. Makes several passes through the array, selecting the next smallest item
in the array each time and placing it where it belongs in the array -
Selection sort
2. At each stage , compare the sought key values with the key value of the
middle element of the array.—Binary search.
When there are multiple definitions with the same function name , what
makes them different from each other ?
It signifies that the function will not return any value to the calling function.
The scope is from the line it is declared until the closing curly brace of the
method within which it is declared.
Only one
If in the switch, break is not present in any case, the control goes to the
next case. This execution of more than one case at a time is called
“Fall through”.
BufferedReader—java.io Scanner—java.util
Give the difference between entry controlled loop and exit controlled
loop?
In entry controlled loop the condition is checked at the entry of the loop. If
false, loop is never executed. Hence minimum iteration could be 0
also. In exit controlled loop, condition is checked at the end of the
loop. So loop is executed at least once.
A boolean literal can have either true or false. A character literal is a single
character enclosed within a pair of single quotes.
Give one similarity and one difference between while and for loop?
Difference – While loop is used when number of iteration is not known and
for loop is used for number of iteration is known.
Public member can be accessed from any other class. Private members can
only be accessed within the declared class.