Text
Class 7A and 7C notes on number System
NUMBER SYSTEM
Answer the following questions:
1) What is a number system?
Ans. A computer understands only numbers. Words, numbers, colours, drawings, audios or videos are translated and stored as large numbers. The way in which the numbers are expressed is known as the number system.
2) Describe the different number systems.
Ans. The different number systems are as follows:
i) Binary Number System (base 2): It consists of only two digits – 0 and 1. It is the most fundamental number system used in digital computers.
ii)Octal Number System ((base 8): It consists of 8 digits – 0 to 7.
iii) Decimal Number System (base 10): It consists of 10 digits – 0 to 9. It is the most widely used number system.
iv) Hexadecimal Number System (base 16): It consists of 16 digits – 0 to 9 and A, B, C, D, E and F.
3) Define the term ‘base’.
Ans. The total number of digits in a number system is known as ‘base’.
4) Why are subscripts used to convert numbers from binary to decimal, or decimal to binary?
Ans. We use subscripts as base to represent numbers when binary is converted to decimal or binary is converted to decimal to avoid confusion or errors.
5) Which number system is used in digital computers?
Ans. The ‘binary number system’ is used in digital computers.
6) Define LSD and MSD?
Ans. In the decimal number system, the rightmost digit of a number has the lowest weight and hence is called Least Significant Digit(LSD) while the leftmost digit has the highest weight and hence is called the Most Significant Digit(MSD).
7) Who invented the binary number system?
Ans. The binary number system was invented by a German mathematician, Gottfried Leibniz.
8) Define MSB and LSB.
Ans. In a binary number, the leftmost bit has the highest value and is called the Most Significant Bit (MSB) while the rightmost bit has the lowest value and is called the Least Significant Bit (LSB).
*******************************************************
0 notes
Text
class 10 computer string chapter explanation: Java
Introduction to Java String Handling
String is probably the most commonly used class in java library. String class is encapsulated under java.lang package. In java, every string that you create is actually an object of type String. One important thing to notice about string object is that string objects are immutable that means once a string object is created it cannot be altered. In Java, java.lang.String class is implementes using Serializable, Comparable and CharSequence interface.
In Java, CharSequence Interface is used for representing a sequence of characters. CharSequence interface is implemented by String, StringBuffer and StringBuilder classes. This three classes can be used for creating strings in java.
What is an Immutable object?
An object whose state cannot be changed after it is created is known as an Immutable object. String, Integer, Byte, Short, Float, Double and all other wrapper classes objects are immutable.
Creating an Immutable class
public final class MyString
{
final String str;
MyString(String s)
{
this.str = s;
}
public String get()
{
return str;
}
}
In this example MyString is an immutable class. MyString's state cannot be changed once it is created. Creating a String object
String can be created in number of ways, here are a few ways of creating string object.
1) Using a String literal
String literal is a simple string enclosed in double quotes " ". A string literal is treated as a String object.
String str1 = "Hello";
2) Using another String object
String str2 = new String(str1);
3) Using new Keyword
String str3 = new String("Java");
4) Using + operator (Concatenation)
String str4 = str1 + str2;
or,
String str5 = "hello"+"Java";
Each time you create a String literal, the JVM checks the string pool first. If the string literal already exists in the pool, a reference to the pool instance is returned. If string does not exist in the pool, a new string object is created, and is placed in the pool. String objects are stored in a special memory area known as string constant pool inside the heap memory.
Concatenating String
There are 2 methods to concatenate two or more string.
1. Using concat() method
2. Using + operator
1) Using concat() method
string s = "Hello";
string str = "Java";
string str2 = s.concat(str);
String str1 = "Hello".concat("Java"); //works with string literals too.
2) Using + operator
string str = "Rahul";
string str1 = "Dravid";
string str2 = str + str1;
string st = "Rahul"+"Dravid";
String Comparison
String comparison can be done in 3 ways.
1. Using equals() method
2. Using == operator
3. By CompareTo() method
Using equals() method
equals() method compares two strings for equality. Its general syntax is,
boolean equals (Object str)
It compares the content of the strings. It will return true if string matches, else returns false.
String s = "Hell";
String s1 = "Hello";
String s2 = "Hello";
s1.equals(s2); //true
s.equals(s1) ; //false
Using == operator
== operator compares two object references to check whether they refer to same instance. This also, will return true on successful match.
String s1 = "Java";
String s2 = "Java";
String s3 = new string ("Java");
test(s1 == s2) //true
test(s1 == s3) //false
By compareTo() method
compareTo() method compares values and returns an int which tells if the string compared is less than, equal to or greater than the other string. It compares the String based on natural ordering i.e alphabetically. Its general syntax is,
int compareTo(String str)
String s1 = "Abhi";
String s2 = "Viraaj";
String s3 = "Abhi";
s1.compareTo(S2); //return -1 because s1 < s2
s1.compareTo(S3); //return 0 because s1 == s3
s2.compareTo(s1); //return 1 because s2 > s1
Java String class functions
The methods specified below are some of the most commonly used methods of the String class in Java. We will learn about each method with help of small code examples for better understanding.
charAt() method
charAt() function returns the character located at the specified index.
String str = "studytonight";
System.out.println(str.charAt(2));
Output: u
NOTE: Index of a String starts from 0, hence str.charAt(2) means third character of the String str. equalsIgnoreCase() method
equalsIgnoreCase() determines the equality of two Strings, ignoring thier case (upper or lower case doesn't matters with this fuction ).
String str = "java";
System.out.println(str.equalsIgnoreCase("JAVA"));
Output: true
indexOf() method
indexOf() function returns the index of first occurrence of a substring or a character. indexOf() method has four forms:
· int indexOf(String str): It returns the index within this string of the first occurrence of the specified substring.
· int indexOf(int ch, int fromIndex): It returns the index within this string of the first occurrence of the specified character, starting the search at the specified index.
· int indexOf(int ch): It returns the index within this string of the first occurrence of the specified character.
· int indexOf(String str, int fromIndex): It returns the index within this string of the first occurrence of the specified substring, starting at the specified index.
Example:
public class StudyTonight {
public static void main(String[] args) {
String str="StudyTonight";
System.out.println(str.indexOf('u')); //3rd form
System.out.println(str.indexOf('t', 3)); //2nd form
String subString="Ton";
System.out.println(str.indexOf(subString)); //1st form
System.out.println(str.indexOf(subString,7)); //4th form
}
}
Java String class functions
The methods specified below are some of the most commonly used methods of the String class in Java. We will learn about each method with help of small code examples for better understanding.
charAt() method
charAt() function returns the character located at the specified index.
String str = "studytonight";
System.out.println(str.charAt(2));
Output: u
equalsIgnoreCase() method
equalsIgnoreCase() determines the equality of two Strings, ignoring thier case (upper or lower case doesn't matters with this fuction ).
String str = "java";
System.out.println(str.equalsIgnoreCase("JAVA"));
Output: true
indexOf() method
indexOf() function returns the index of first occurrence of a substring or a character. indexOf() method has four forms:
int indexOf(String str): It returns the index within this string of the first occurrence of the specified substring.
int indexOf(int ch, int fromIndex): It returns the index within this string of the first occurrence of the specified character, starting the search at the specified index.
int indexOf(int ch): It returns the index within this string of the first occurrence of the specified character.
int indexOf(String str, int fromIndex): It returns the index within this string of the first occurrence of the specified substring, starting at the specified index.
Example:
public class StudyTonight {
public static void main(String[] args) {
String str="StudyTonight";
System.out.println(str.indexOf('u')); //3rd form
System.out.println(str.indexOf('t', 3)); //2nd form
String subString="Ton";
System.out.println(str.indexOf(subString)); //1st form
System.out.println(str.indexOf(subString,7)); //4th form
}
}
length() method
length() function returns the number of characters in a String.
String str = "Count me";
System.out.println(str.length());
8
replace() method
replace() method replaces occurances of character with a specified new character.
String str = "Change me";
System.out.println(str.replace('m','M'));
Output: Change Me
substring() method
substring() method returns a part of the string. substring() method has two forms,
public String substring(int begin);
public String substring(int begin, int end);
/*
character of begin index is inclusive and character of end index is exclusive.
*/
The first argument represents the starting point of the subtring. If the substring() method is called with only one argument, the subtring returned, will contain characters from specified starting point to the end of original string.But, if the call to substring() method has two arguments, the second argument specify the end point of substring.
String str = "0123456789";
System.out.println(str.substring(4));
456789
System.out.println(str.substring(4,7));
Output:456
toLowerCase() method
toLowerCase() method returns string with all uppercase characters converted to lowercase.
String str = "ABCDEF";
System.out.println(str.toLowerCase());
Output:abcdef
toUpperCase() method
This method returns string with all lowercase character changed to uppercase.
String str = "abcdef";
System.out.println(str.toUpperCase());
Output:ABCDEF
trim() method
This method returns a string from which any leading and trailing whitespaces has been removed.
String str = " hello ";
System.out.println(str.trim());
Output:hello
NOTE: If the whitespaces are between the string, for example: String s1 = "study tonight"; then System.out.println(s1.trim()); will output "study tonight".
trim() method removes only the leading and trailing whitespaces.
Extra note:
format() Method
format() is a string method. It is used to the format of the given string.
Following are the format specifier and their datatype:
Format Specifier Datatype
%a
floating point
%b
Any type
%c
character
%d
integer
%e
floating point
%f
floating point
%g
floating point
%h
any type
%n
none
%o
integer
%s
any type
%t
Date/Time
%x
integer
public class FormatDemo1
{
public static void main(String[] args)
{
String a1 = String.format("%d", 125);
String a2 = String.format("%s", "studytonight");
String a3 = String.format("%f", 125.00);
String a4 = String.format("%x", 125);
String a5 = String.format("%c", 'a');
System.out.println("Integer Value: "+a1);
System.out.println("String Value: "+a2);
System.out.println("Float Value: "+a3);
System.out.println("Hexadecimal Value: "+a4);
System.out.println("Char Value: "+a5); }}
";msoū��g�
0 notes
Text
chapter 4: Question & Answer for class 9 java.
Question 1
What is meant by data type? Name two types of data type.
Data types are used to identify the type of data a memory location can hold and the associated operations of handling it. Data Types are of two types:
Primitive Data Types
Reference or Composite Data Types
Question 2
Why is it necessary to define data type in Java programming?
Data types tells Java how much memory it should reserve for storing the value. Data types also help in preventing errors as the compiler can check and flag illegal operations at compile time itself.
Question 3
Define the following with an example:
(a) variable A variable represents a memory location through a symbolic name which holds a known or unknown value of a particular data type. This name of the variable is used in the program to refer to the stored value. Example: int mathScore = 95;
(b) constant The keyword final before a variable declaration makes it a constant. Its value can't be changed in the program. Example: final int DAYS_IN_A_WEEK = 7;
(c) boolean data type A boolean data type is used to store one of the two boolean values — true or false. The size of boolean data type is 8 bits or 1 byte. Example: boolean bTest = false;
(d) coercion In a mixed-mode expression, the process of promoting a data type into its higher most data type available in the expression without any intervention by the user is known as Coercion. Example:
byte b = 42;
int i = 50000;
double result = b + i;
(e) primitive data type Primitive data types are the basic or fundamental data types used to declare a variable. Examples of primitive data types in Java are byte, short, int, long, float, double, char, boolean.
(f) non-primitive data type A non-primitive data type is one that is derived from Primitive data types. A number of primitive data types are used together to represent a non-primitive data type. Examples of non-primitive data types in Java are Class and Array.
Question 4
What is a token? Name different types of tokens.
A token is the smallest element of a program that is meaningful to the compiler. The different types of tokens in Java are:
Identifiers
Literals
Operators
Separators
Keywords
Question 5
Explain the term type casting.
The process of converting one predefined type into another is called type casting.
Question 6
Assign the following to a variable with suitable data type.
(a) m = 22 / 7
double m = (22.0 / 7.0);
(b) p= 1.4142135 (value of square root of 2)
double p = 1.4142135;
(c) k= 0.00004545
double k = 0.00004545;
(d) n=24.50
float n = 24.50f;
Question 7
Distinguish between:
(a) Token and Identifier
Token
Identifier
A token is the smallest element of a program that is meaningful to the compiler.
Identifiers are used to name things like classes, objects, variables, arrays, functions an so on.
(b) Character and Boolean literal
Character literal
Boolean literal
Character literals are written by enclosing a character within a pair of single quotes.
A boolean literal can take only one of the two boolean values represented by the words true or false.
Character literals can be assigned to variables of any numeric data type — byte, short, int, long, float, double, char
Boolean literals can only be assigned to variables declared as boolean
Escape Sequences can be used to write character literals
Only true and false values are allowed for boolean literals
Question 8
Explain the term type conversion. How is implicit conversion different from explicit conversion?
The process of converting one predefined type into another is called type conversion. In an implicit conversion, the result of a mixed mode expression is obtained in the higher most data type of the variables without any intervention by the user. For example:
int a = 10;
float b = 25.5f, c;
c = a + b;
In case of explicit type conversion, the data gets converted to a type as specified by the programmer. For example:
int a = 10;
double b = 25.5;
float c = (float)(a + b);
Question 9
Classify the following as primitive or non-primitive data types.
(a) char Primitive
(b) arrays non-primitive
(c) int Primitive
(d) classes non-primitive
Question 10
In what way is static initialization of data type different from dynamic initialization?
In static initialization, the initial value of the variable is provided as a literal at the time of declaration. For example:
int mathScore = 100;
double p = 1.4142135;
char ch = 'A';
In dynamic initialization, the initial value of the variable is the result of an expression or the return value of a method call. Dynamic initialization happens at runtime. For example:
int a = 4;
int b = Math.sqrt(a);
double x = 3.14159, y = 1.4142135;
double z = x + y;
Question 11
Predict the return data type of 'r' and 'n' from the snippet:
int p; float m;
r = p+m;
n = m/3*(Math.pow(4,3));
System.out.println(r);
System.out.println(n);
Return type of r is float and n is double.
Question 12
Give reason whether the following assignments are correct or not:
(a) int m =155; This assignment is correct as 155 is an integer literal and it is assigned to an int variable m.
(b) float f = 0.002654132; This assignment is incorrect as data type of 0.002654132 is double but it is assigned to a float variable. The correct assignment will be float f = 0.002654132f;
(c) String str = 'Computer'; This assignment is incorrect as the String literal Computer is enclosed in single quotes. It should be in double quotes. The correct assignment will be String str = "Computer";
(d) boolean p = false; This assignment is correct as false is a valid boolean literal and it is assigned to a boolean variable.
(e) String b = "true"; This assignment is correct as "true" is a string literal not a boolean literal as it is enclosed in double quotes. It is correctly assigned to a String variable.
(f) char ch = "apps"; This assignment is incorrect as "apps" is a string literal not a character literal and it is assigned to a variable ch of char data type.
(g) String st= "Application"; This assignment is correct as "Application" is a string literal and it is correctly assigned to a String variable.
(h) double n = 455.29044125; This assignment is correct as 455.29044125 is a literal of double data type and it is correctly assigned to a double variable.
0 notes
Text
class 9 operators chapter in java
CLASS 9 Chapter 4 : Operators in Java
We use Operators to perform operations on variables and values. Operators are represented by symbols. The variables and values on which operators perform operation are called operands. Let’s look at this code snippet:
int x = a + 10;
Here, plus sign is the operator, the variable a and the literal value 10 are operands.
Forms of Operators
Depending on the number of operands an operator operates upon, we classify them into 3 forms:
1. Unary
Binary
Ternary
Unary Operators work on a single operand, binary on 2 operands and ternary on 3 operands. Most of the operators in Java are binary, a few are unary. There is only one ternary operator in Java.
Types of Operators
Based on the type of operation performed by the operator, we can group them into the following types:
1. Arithmetic
Relational
Logical
Assignment
Bitwise
We will look at Arithmetic, Relational, Logical and Assignment type of operators. As Bitwise operators are not included in ICSE syllabus, so they are out of scope for this course.
Basic Arithmetic Operators
We use Arithmetic operators to perform common mathematical operations. Operands of Arithmetic operators must be of numeric type. This implies that Arithmetic operators can operate on byte, short, int, long, float, double and char. But they cannot operate on boolean.
This table lists all the different Arithmetic operators in Java:
Operator
Name
Description
Example
Unary +
Unary Plus
Returns value of the operand
+x
Unary -
Unary minus
Returns negated value of the operand
-x
+
Addition
Adds together two values
x + y
-
Subtraction
Subtract one value from another
x - y
*
Multiplication
Multiplies two values
x * y
/
Division
Divides one value from another
x / y
%
Modulus
Returns the division remainder
x % y
++
Increment
Increases the value of a variable by 1
++x or x++
--
Decrement
Decreases the value of a variable by 1
--x or x--
The first six - Unary Plus, Unary Minus, Addition, Subtraction, Multiplication and Division are the same as in algebra.
Let’s look at a BlueJ program to see these operators in action:
public class BasicArithmeticOperators
{
public static void main(String args[]) {
/*
* Addition operator adds both
* of its operands 10 and 10
* to give the result as 20
*/
int a = 10 + 10;
/*
* Multiplication operator
* multiplies its first
* operand which in this
* case is the variable a
* with its second operand
* which is the integer
* literal 3 to give the
* result as 60
*/
int b = a * 3;
/*
* Division operator divides
* its first operand with
* second so b which has a
* value of 60 is divided by
* 4 to give the result as 15
*/
int c = b / 4;
/*
* Subtraction operator subtracts
* the second operand from the
* first so a is subtracted from
* c to give the result as -5
*/
int d = c - a;
/*
* Unary Minus operator negates
* the value of its operand.
* d has the value of -5.
* On negation it becomes 5
* and gets assigned to e
*/
int e = -d;
System.out.println("a = " + a);
System.out.println("b = " + b);
System.out.println("c = " + c);
System.out.println("d = " + d);
System.out.println("e = " + e);
}
}
Please run the program and see the output.
The modulus operator computes the remainder of a division operation. Let’s look at a BlueJ program to understand its usage:
public class ModulusOperator
{ public static void main (String args[]) {
/** Modulus operator computes
* the remainder of a
* division operation.
*/
int a = 59;
double b = 59.75;
System.out.println("a % 10 = " + a % 10);
System.out.println("b % 10 = " + b % 10);
}}
Increment and Decrement Operators
Increment and decrement operators are unary operators, they operate on only one operand.The increment operator ++ adds 1 to the value of its operand and the decrement operator -- subtracts 1 from the value of its operand. The statement
a = a + 1;
can be rewritten using increment operator like this:
a++;
Similarly, this statement:
a = a - 1;
can be rewritten using decrement operator like this:
a--;
The increment and decrement operators have a special property unique to them. We can use them in postfix form where they follow the operand. We used this form in the example above. We can also use them in prefix form where they precede the operand.
Prefix and Postfix Increment and Decrement Operators
Let’s look at the below BlueJ program to understand the Prefix form of these operators:
public class PrefixIncrement
{ public static void main(String args[]) {
int a = 99;
/*
* With Prefix increment
* first a is incremented
* to 100. After that
* a is assigned to b
*/
int b = ++a;
System.out.println("a = " + a);
System.out.println("b = " + b);
}
}
Prefix form follows the CHANGE-THEN-USE rule. The prefix increment operator which we applied to a, will first increment the value of a by 1, making its value 100. After the increment, the incremented value of a gets assigned to b. Once the two statements finish executing, both a and b will have the value of 100.
Now let’s look at the postfix form:
public class PostfixIncrement
{ public static void main(String args[]) {
int a = 99;
/*
* With Postfix increment
* first a is assigned to
* b. After that a is
* incremented
*/
int b = a++;
System.out.println("a = " + a);
System.out.println("b = " + b);
}
}
Postfix form follows the USE-THEN-CHANGE rule. In the postfix case, first the original value of a which is 99 gets assigned to b. After the assignment, the postfix increment operator increments the value of a to 100. Once the two statements finish executing, a will have the value of 100 and b will have the value of 99.
Prefix and Postfix Decrement operators work in a similar way to their Increment counterparts. Instead of increasing the value, they decrease the value by 1.
Assignment and Shorthand Operators We use Assignment operators to assign values to variables.
int x = 10;
In the above statement, we use the assignment operator ( = ) to assign the value 10 to x.
Shorthand Operators
Statements like this:
a = a + 10;
are used a lot in programs. Java provides shorthand operators to combine the arithmetic and assignment operator into a single operator and write the above statement like this:
a += 10;
Both these statements are equivalent. They add 10 to a and assign the value back to a. The second statement uses the shorthand operator and is a little simple and saves a bit of typing.
There are shorthand operators for all arithmetic binary operators. The table below lists some of the shorthand operators in Java:
Operator
Example
Same As
+=
x += 5
x = x + 5
-=
x -= 5
x = x - 5
*=
x *= 5
x = x * 5
/=
x /= 5
x = x / 5
%=
x %= 5
x = x % 5
Let’s look at a BlueJ program to see some examples of Shorthand operator’s usage:
public class ShorthandOp
{
Public static void main(String args[]) {
int x = 10, y = 20, z = 30;
x += 20; //Same as x = x + 20
y *= 3; //Same as y = y * 3
z -= 15; //Same as z = z - 15
z += x * y; //Same as z = z + (x * y)
z %= 7; //Same as z = z % 7
System.out.println("x = " + x);
System.out.println("y = " + y);
System.out.println("z = " + z);
}
}
0 notes
Text
For the students of class 5 SES
CHAPTER 2 :TYPES OF SOFTWARE
Answer the following questions:
1) What is a software? Give examples.
Ans. A software is a set of programs that controls the operations of a computer. Examples are MS Paint, MS Word, Calculator, Notepad etc.
2) What is operating system? What are the functions of an operating system?
Ans. An operating system is the interface between the user and computer.
The functions of an operating system are:
i) It controls all the application software running on a computer.
ii) It assigns the hardware needed to perform a task.
iii) It allocates memory required for each task.
iv) It helps in creation and deletion of files and folders.
v) It manages the data stored in the memory.
3) What is the use of a language translator?
Ans. A translator is used to translate the instructions into binary language.
4) What is scanning? Why is it useful for computers?
Ans. Scanning is the process to detect and correct the problems that arise on a computer system.
It is useful to detect computer viruses.
5) What is presentation software? Give two examples.
Ans. Presentation software is used to create presentations that can be displayed as slide show. Two examples are: Microsoft PowerPoint and Corel Presentation.
6) Name and explain the two types of software.
Ans. The two types of software are:
i) System Software: These are the programs designed to control the operations of a computer system.
ii) Application Software: These are programs designed to help us perform certain types of task.
7) What is Customized software?
Ans. Customized software refers to the software designed to fulfill the requirements of a particular client.
0 notes
Text
Spreadsheet: Functions and Charts
For Class 8B of SES Students
CLASS 8B for SES STUDENTS COMPUTER NOTES ON CHAPTER 2 (Spreadsheet: Functions and Charts)
Objective
I. State whether the following statements are true or false:
1. A range of cells is a group of cells that have been selected and which form a shape of a rectangular box. True
2. A spread sheet can only contain numeric data. False
3. You can insert a chart but not clipart in a worksheet. False
4. The Cell in which the cell pointer is located in a worksheet is the active cell. True
5. You can select a range of data as per your choice in a spreadsheet. True
II. Fill in the blanks:
1. Charts are the Pictorial representation of data values stored in the worksheet.
2. When the corresponding cell address changes with reference to a new cell address, it is known as Relative reference.
3. By default, MS Excel provide Three worksheets in a workbook.
4. The built-in formulae for specific numeric/non-numeric processing are called Function .
5. Range of cells is a rectangular block consisting of few cells, an entire row, an entire column or the whole worksheet.
III. Write the format of the function used in MS Excel to perform the following tasks:
1. To calculate the average of 82,67,80,74 and 95.
= AVERAGE(82,67,80,74,95)
2. To find the highest value of the cell references from D3 to K3.
= MAX(D3:K3)
3. To calculate the sum of the first five multiples of 7.
= SUM (7,14,21,28,35)
4. To determine the lowest value of the cell reference from A4 to A12.
= MIN (A4:A12)
5. To find the sum of all the prime numbers from 1 to 10.
= SUM (2,3,5,7)
6. To find the arithmetical mean of the cell references from E4 to K4.
= AVERAGE (E4:K4)
Subjective
I. Explain the meaning of the following functions:
1. =SUM(C5:H5)
calculates the sum of the cell values from C5 to H5
2. = AVERAGE (K12:K50)
Calculates the average of the cell values from K12 to K50
3. = COUNT (B15:B35)
This will return the value 21 as there are twenty one entries.
4. = MAX (A4:A14)
It will return the highest value among the cells A4 to A14
II. Define the following:
1. Relative Referencing
Relative reference is one of the types of cell reference in excel, it is the type of reference which changes when the same formula is copied to any other cells or in any other worksheet, suppose in cell A1 we have =B1+C1 and when we copy this formula to cell B2 the formula becomes C2+D2, why because in the first formula the cells were referred to the two right cells of cell A1 while in the second formula the two cells on the right are c2 and d2.
2. Absolute Referencing
Absolute reference in excel is used when we want to fix the position of the selected cell in any formula so that its value will be not changed whenever we are changing the cell or copying the formula to other cells or sheets. This is done by putting the dollar (“$”) sign before and after the column name of the selected cell. Or else, we can type F4 function key which will automatically cover the column alphabet with the dollar. For example, if you want to fix the cell A1 then it will look as “=$A$1”.
3. Mixed Referencing
Mixed referencing is a combination of relative and absolute referencing. In this reference, the data of one cell is kept absolute and other is made relative and they operate together in a formula. For example, cell B3 can be made absolute and cell B4 can be made relative by representing them as $B$3 and B$4.
**********************************************************************************************
Lab Activity to do it at home.
Multiplication table
To illustrate the use of a mixed reference, we will construct a multiplication table.
The idea here is to create a single formula and copy it for the rest of the document. This will save us writing the 99 other formulas
Formula with mixed reference
We want to stay always on the headers of our table so we will write the formula as follows
=$B4*C$3
1. Start by copying cell C4 (Ctrl + C)
2. Then select all other cells
3. Finally, paste the formula (Ctrl + V)
The multiplication table is now correct for every single cell.
We have created only one formula and copied it for the 99 other cells. How productive
Multiplication table
0 notes
Text
Class 9 Computer: Chapter 3 Notes
Chapter 3: Values and Data Types
State whether the following statements are 'True' or 'False'
Question 1
There are 128 set of different characters used in a Java program. False
Explanation: Java uses Unicode which can represent much more than 128 characters
Question 2
The ASCII codes of upper case letters range from 97 to 122. False
Explanation: ASCII codes of upper case letters range from 65 to 90
Question 3
A variable gives the exact representation of data. False
Explanation: A literal gives exact representation of data. As value of variable can change, so it cannot give exact representation of data.
Question 4
The data types int, float, char are called non-primitive types. False
Explanation: The data types int, float, char are called Primitive types.
Question 5
A String literal is assigned to a String variable. True
Explanation: The data type of the variable that can hold a String literal should also be String.
Question 6
A character literal is always enclosed in double quotes. False
Explanation: A character literal is enclosed in single quotes.
Question 7
String constant can be written by using a set of alphanumeric characters. True
Explanation: A String literal or String constant is defined by enclosing a set of alphanumeric characters within double quotes.
Question 8
An object is said to be a non-primitive data. True
Explanation: Class is a non-primitive data type so Objects are non-primitive data.
Question 9
The data type int stores fractional values. False
Explanation: float or double data type stores fractional values.
Question 10
Boolean type data is used to test a condition and results in either true or false. True
Explanation: Boolean data type can be either true or false.
Write short answers:
Question 1
What is meant by data type? Name two types of data type.
Data types are used to identify the type of data a memory location can hold and the associated operations of handling it. Data Types are of two types:
Primitive Data Types
Reference or Composite Data Types
Question 2
Why is it necessary to define data type in Java programming?
Data types tells Java how much memory it should reserve for storing the value. Data types also help in preventing errors as the compiler can check and flag illegal operations at compile time itself.
Question 3
Define the following with an example:
(a) variable A variable represents a memory location through a symbolic name which holds a known or unknown value of a particular data type. This name of the variable is used in the program to refer to the stored value. Example: int mathScore = 95;
(b) constant The keyword final before a variable declaration makes it a constant. Its value can't be changed in the program. Example: final int DAYS_IN_A_WEEK = 7;
(c) boolean data type A boolean data type is used to store one of the two boolean values — true or false. The size of boolean data type is 8 bits or 1 byte. Example: boolean bTest = false;
(d) coercion In a mixed-mode expression, the process of promoting a data type into its higher most data type available in the expression without any intervention by the user is known as Coercion. Example:
byte b = 42;
int i = 50000;
double result = b + i;
(e) primitive data type Primitive data types are the basic or fundamental data types used to declare a variable. Examples of primitive data types in Java are byte, short, int, long, float, double, char, boolean.
(f) non-primitive data type A non-primitive data type is one that is derived from Primitive data types. A number of primitive data types are used together to represent a non-primitive data type. Examples of non-primitive data types in Java are Class and Array.
Question 4
What is a token? Name different types of tokens.
A token is the smallest element of a program that is meaningful to the compiler. The different types of tokens in Java are:
Identifiers
Literals
Operators
Separators
Keywords
Question 5
Explain the term type casting.
The process of converting one predefined type into another is called type casting.
Question 6
Assign the following to a variable with suitable data type.
(a) m = 22 / 7
double m = (22.0 / 7.0);
(b) p= 1.4142135 (value of square root of 2)
double p = 1.4142135;
(c) k= 0.00004545
double k = 0.00004545;
(d) n=24.50
float n = 24.50f;
Question 7
Distinguish between:
(a) Token and Identifier
Token
Identifier
A token is the smallest element of a program that is meaningful to the compiler.
Identifiers are used to name things like classes, objects, variables, arrays, functions an so on.
(b) Character and Boolean literal
Character literal
Boolean literal
Character literals are written by enclosing a character within a pair of single quotes.
A boolean literal can take only one of the two boolean values represented by the words true or false.
Character literals can be assigned to variables of any numeric data type — byte, short, int, long, float, double, char
Boolean literals can only be assigned to variables declared as boolean
Escape Sequences can be used to write character literals
Only true and false values are allowed for boolean literals
Question 8
Explain the term type conversion. How is implicit conversion different from explicit conversion?
The process of converting one predefined type into another is called type conversion. In an implicit conversion, the result of a mixed mode expression is obtained in the higher most data type of the variables without any intervention by the user. For example:
int a = 10;
float b = 25.5f, c;
c = a + b;
In case of explicit type conversion, the data gets converted to a type as specified by the programmer. For example:
int a = 10;
double b = 25.5;
float c = (float)(a + b);
Question 9
Classify the following as primitive or non-primitive data types.
(a) char Primitive
(b) arrays non-primitive
(c) int Primitive
(d) classes non-primitive
Question 10
In what way is static initialization of data type different from dynamic initialization?
In static initialization, the initial value of the variable is provided as a literal at the time of declaration. For example:
int mathScore = 100;
double p = 1.4142135;
char ch = 'A';
In dynamic initialization, the initial value of the variable is the result of an expression or the return value of a method call. Dynamic initialization happens at runtime. For example:
int a = 4;
int b = Math.sqrt(a);
double x = 3.14159, y = 1.4142135;
double z = x + y;
Question 11
Predict the return data type of 'r' and 'n' from the snippet:
int p; float m;
r = p+m;
n = m/3*(Math.pow(4,3));
System.out.println(r);
System.out.println(n);
Return type of r is float and n is double.
Question 12
Give reason whether the following assignments are correct or not:
(a) int m =155; This assignment is correct as 155 is an integer literal and it is assigned to an int variable m.
(b) float f = 0.002654132; This assignment is incorrect as data type of 0.002654132 is double but it is assigned to a float variable. The correct assignment will be float f = 0.002654132f;
(c) String str = 'Computer'; This assignment is incorrect as the String literal Computer is enclosed in single quotes. It should be in double quotes. The correct assignment will be String str = "Computer";
(d) boolean p = false; This assignment is correct as false is a valid boolean literal and it is assigned to a boolean variable.
(e) String b = "true"; This assignment is correct as "true" is a string literal not a boolean literal as it is enclosed in double quotes. It is correctly assigned to a String variable.
(f) char ch = "apps"; This assignment is incorrect as "apps" is a string literal not a character literal and it is assigned to a variable ch of char data type.
(g) String st= "Application"; This assignment is correct as "Application" is a string literal and it is correctly assigned to a String variable.
(h) double n = 455.29044125; This assignment is correct as 455.29044125 is a literal of double data type and it is correctly assigned to a double variable.
0 notes
Text
Arrays Chapter
Tick the correct answer
Question 1
Which of the following is the correct usage?
int a[-40]
int a[40]
float a[0 - 40]
None
Question 2
Which element is represented by a[10]?
10th
9th
11th
None
Question 3
Cell numbers of a dimensional array are also known as:
packets
blocks
subscripts
compartments
Question 4
A dimensional array is also known as:
subscripted variable
actual variable
compound variable
none
Question 5
An array element can be accessed through:
dots
element name
index number
none
Question 6
Indicate the error message which displays, if the following statement is executed : int a[5] = {28,32,45,68,12};
Insufficient cells
Array index out of bounce
Elements exceeding cells
None
Question 7
The following statement : int code[ ]= {25,37,38,42};
assigns 37 to code[1]
assigns 25 to code[1]
assigns 38 to code[3]
assigns 42 to code[0]
Question 8
The elements of array[50] are numbered:
from 1 to 50
from 0 to 49
from 1 to 51
none
Question 9
Which of the following function finds the size of array char m[] = {'R', 'A', 'J', 'E', 'N', 'D', 'R', 'A' };?
m.size of (a)
m.elements of (m)
m.length
None
Question 10
A Single Dimensional array contains N elements. What will be the last subscript?
N-1
N
N+1
None
next post will updated soon.
2 notes
·
View notes