0% found this document useful (0 votes)
38 views

Computer Theory

The document discusses different types of methods in object-oriented programming including static and non-static functions. It also covers topics like function overloading, autoboxing, recursion, wrapper classes and more.

Uploaded by

dhruv manshani
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
38 views

Computer Theory

The document discusses different types of methods in object-oriented programming including static and non-static functions. It also covers topics like function overloading, autoboxing, recursion, wrapper classes and more.

Uploaded by

dhruv manshani
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Thursday, 22 February 2024

Computer Theory

Computer Applications
A Method is a block of code that performs a speci c task.

Calling A Function :

Call By Value - A function is called through values/variables as arguments of that


class. It refers to copying the value of the original variable, so as to make sure that
any changes made are not re ected in the original variable/value.

Call By Reference - A function is called with objects of that class as arguments, it


is known as call by Reference. Instead of copying, the formal parameters are
references to the actual parameters. So, any changes made will be re ected in the
original value.

Static Function - A function that can be called without creating an object of that
class is called a static function. It can only have Static (class) Variables.

Non Static Function - A function that can be called through the object of that class
is called a Non-Static Function. It can have both Non-Static and Static variables.

Static Variables (Class Variable) - The declaration of the variable includes the
'static' keyword. Only one copy of the variable exists per class. Static variables are
created at the start of program execution and destroyed automatically when
execution ends.

Non-Static Variable (Instance Variable) - The declaration of the variable does not
include the 'static' keyword. They are created when a new object is created and
destroyed when the object is destroyed.

Types Of Methods :

User - De ned Methods

Standard Library Methods

Function Prototype - First line of the function de nition.

Eg. Public static double joyString(int a. double b)

Function Signature - It includes the name of the method and parameter types.

Eg. joyString(int a, double b);

1

fi
fl
fi
fi
fl
Actual Parameters - The Parameters used while calling the function are Actual
Parameters.

Formal Parameters - The Parameters used in the header of the function de nition
are called formal parameters.

Method Overloading - Having more than one method in a single class with the
same name with a di erent argument lists is called function overloading.

Autoboxing - The automatic conversion of a value of a primitive data type to it's


corresponding wrapper class is called Autoboxing.

Eg. int a = 42;

Integer it = a;

Unboxing - The conversion of a wrapper class obejct to it's coreesponding


primitive data type is called Unboxing.

Eg. Integer a = 42;

int it = a;

Pure Function - A function that does not change the state of an object is called a
pure function.

Impure Function - A function that changes the state of an object is called an


impure function.

Integer.pareInt() - It is used to convert a string representation to int data type.

Integer.valueOf() - It accepts a String or int as a parameter and returns an Integer


Object holding the value of the argument passed.

Integer.parseInt() Integer.valueOf()

It only accepts String. It accepts both int and String.

It return primitive int. It returns Integer object.

Escape Sequences - They are used to represent those characters that are either
reserved or not available on keyboard.

Eg. '\n', '\b', '\\', '\'', '\"'

Immutable - Which cannot be changed directly and needs to be overwritten.

2

ff
fi
Eg. String

Unicode - Two byte character set to represent characters of various languages.


ASCII is a subset of Unicode.

Compound Statement - More than two statements in {}. Also called a block.

Recursion - When a function calls itself

Eg. public void abc()

abc();

IDE - Integrated Development Environment. We can edit, compile, debug our code.

Eg. BlueJ

Source Code - An uncompiled java program.

Object Code - Code that can be understood by the Machine. Source code is
converted into Object code.

Compiler - It converts the source code to machine (object) code before execution.

API - Application Programming Interface. [Includes Packages]

Coercion - Implicit Conversion

Type Casting - Explicit Conversion

Bytecode - The java compiler compiles the java source code into Bytecode which
makes Java a platform independent language. It is converted by an interpreter
known as Java Virtual Machine (JVM).

Precedence - Order of evaluation

Associativity : Order of evaluation when precedence is the same.

3

*Order of Associativity - Left---->RIght

Mixed Mode or Impure Expressions - When operands are of di erent data types.

Fixed mode or pure expressions - When operands are of the same data type.

What is the di erence between the rint() and the round() function in Java?

Math.riot() returns a double type value whereas Math.round() returns an integer type
value.

Eg.

System.out.println(Math.rint(5.5));

System.oui.println(Math.round(5 .5));

Output -

6.0

Instance variables - Variables declared outside any method, function, iteration


statements but within the class.

Class Variables - Instance variables declared with the 'static' modi er.

Di erence between Primitive and Composite DataType.

PRIMITIVE DATATYPES COMPOSITE DATATYPES

They are prede ned datatypes that are provided They are derived from the primitive datatypes.
by the language.

They have variable size. They have a xed size.

4

ff
fi
fi
ff
ff
fi
Wrapper Class - The class equivalent of a primitive data type.

Same as that of the primitive data type but starts with a capital letter.

Which package is imported by default? Name some classes in it.

Java.lang

Integer, String, Character

What statement is used for importing a char data type.

ch = sc.next().charAt(0);

Bubble Sort Selection Sort

Matches two consecutive elements matches one element with the rest

Swapping inside inner loop swapping outside the loop

Object oriented Programming mainly uses bottom-up approach.

A program that translates high level language into machine code is called compiler.

A program that translates assembly language into machine code is called an


assembler.

ASCII is a 7-bit set of code (Extended ASCII is 8).

Punctuators are symbols for grouping and separating code.

Wrapper class Integer is available in java.lang

Math.abs returns the value in datatype in which it received the agument.

Math.round returns an int datatype.

When a class is derived from only one base class, it is known as single inheritance.

When a class is derived from many classes, it is known as multiple inheritance.

When many classes are derived from a class, it is known as hierarchal inheritance

When a class is derived from a class that itself is derived from an other class, it is
known as Multi-level inheritance.

When more than one form of inheritance occurs, it is known as hybrid inheritance.

5

You might also like