basic understand document

19
To see the list of process running on the system and also we can see the process run status like automated or manually by using the following path. Move to start->run-> then type the services.msc Equals and hashCode methods are present in Object class, usually if want to compare objects means when override must have to override hashCode, at that time for both objects hashCode value also must be same. If will not override hashCode , and storing object in memory then hashCode is unique. Sample code to create the FiveTon class in Java. Means this piece of the code creates the five instances for the class and 6 th time onwards will assign the instances in round robin fashion like 1 st instance for 6 th call and 2 nd instance for 7 th call. 1. public class Fiveton 2. { 3. private static final Fiveton[] instances = new Fiveton[5]; 4. private static int index = 0; 5. 6. private Fiveton() {} 7. 8. // not thread-safe 9. public static Fiveton getInstance() 10. { 11. if (instances[index] == null)

Upload: venkatramana-settipalli

Post on 23-Oct-2014

16 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: Basic Understand Document

To see the list of process running on the system and also we can see the process run status like automated or manually by using the following path.

Move to start->run-> then type the services.msc

Equals and hashCode methods are present in Object class, usually if want to compare objects means when override must have to override hashCode, at that time for both objects hashCode value also must be same.

If will not override hashCode , and storing object in memory then hashCode is unique.

Sample code to create the FiveTon class in Java. Means this piece of the code creates the five instances for the class and 6th time onwards will assign the instances in round robin fashion like 1st instance for 6th call and 2nd instance for 7th call.

1. public class Fiveton   2. {   3.     private static final Fiveton[] instances = new 

Fiveton[5];   4.     private static int index = 0;   5.   6.     private Fiveton() {}   7.   8.     // not thread-safe   9.     public static Fiveton getInstance()   10.     {   11.         if (instances[index] == null)   12.         {   13.             instances[index] = new Fiveton(); 14.         }   15.         Fiveton instance = instances[index];   16.         index = (index + 1) % instances.length; 17.         return instance;   18.     }   19. }  

Page 2: Basic Understand Document

To convert Binary to integer in java logic:

String binary = "1001";int decimal = Integer.parseInt(binary, 2);System.out.println(decimal);

String hex = Integer.toHexString(decimal);System.out.println(hex);

String octal = Integer.toOctalString(decimal);System.out.println(octal);

Output:9911

To display salary amount in words

SAL (TO_CHAR(TO_DATE(SAL,'J'),'JSP')) --------- -----------------------------------------------------       800 eight hundred      1600 one thousand six hundred      1250 one thousand two hundred fifty If you want to add some text like, Rs. Three Thousand only. SQL> select sal  "Salary ",  (' Rs. '|| (to_char(to_date(sal,'j'), 'Jsp'))|| ' only.'))  "Sal in Words" from emp / Salary  Sal in Words ------- ------------------------------------------------------     800  Rs. Eight Hundred only.    1600  Rs. One Thousand Six Hundred only.    1250  Rs. One Thousand Two Hundred Fifty only.

Display Odd/ Even number of records  Odd number of records: select * from emp where (rowid,1) in (select rowid, mod(rownum,2) from emp); 1 3 5 Even number of records: select * from emp where (rowid,0) in (select rowid, mod(rownum,2) from emp) 2

The command to show the space usage on UNIXdf -lk

Page 3: Basic Understand Document

To control the default file permissions when created in UNIXUnmask

To execute UNIX command in back ground &

To show the list of files under directory and also hidden files in UNIXls –lrta

To replace all occurrences of value in UNIX VI editor :s/old value/new value/g

What are the more common pseudo-columns?

SYSDATE, USER, UID, CURVAL, NEXTVAL, ROWID, ROWNUM

To delete the duplicate records from table based on some field value (column data)

DELETE FROM table_name A WHERE ROWID > ( SELECT min(rowid) FROM table_name B WHERE A.key_values = B.key_values);

To display the all unique employees where salary is equal

Select distinct e.name, e.salary from employee e1 employee e2 where e1.salary = e2.salary and e1.name != e2.name

Default size for StringBuffer is 16 and this values is always length +16 = StringBuffer

size Default size for Vector is 10 and this value is not like always String buffer way, if there

are up to 10 objects in vector then capacity of vector also 10 only. If vector items are 11 or up to 20 its capacity is 20. So vector capacity value always increase 10 but incases of stringbuffer it will increase based on actually length. Understand for ArrayList there is no default size like String buffer or Vector, but its size will get increment 50% every time.

InstanceOf is the word defined in java. But isInstance is method of java.lang.Class, it will return true only for its class. instanceOf will return true for its class and all its sub classes

ArrayList is index based but LinkedList iterator based. Index based is faster because control directly goes to ‘n’ location for particular element, but in case of iterator it has to traverse n- 1 elements to fetch ‘n’ position element. So index based is faster but in order to insert, delete or update element at middle iterator based (Linked list) is faster, if we already know operation (insertion, deletion or updation) will happens at end index based is faster. The bottom line of main reason is ArrayList index based, once element delete, down all the elements has to shift down.

ArrayList uses the System.arrayCopy()) operation internally to shift down or up elements in ArrayList when insertion or deletion happens

What is ConcurrentHashMap?

Ans) A concurrentHashMap is thread-safe implementation of Map interface. In this class put

and remove method are synchronized but not get method. This class is different from

Page 4: Basic Understand Document

Hashtable in terms of locking; it means that hashtable use object level lock but this class uses

bucket level lock thus having better performance.

Which data structure HashSet implements

Ans) HashSet implements hashmap internally to store the data. The data passed to hashset is

stored as key in hashmap with null as value.

In order to make any collection read only call Collections.unmodifiableList(list) etc SQL query to delete duplicate records from table based on particular column

Delete from <table_name> A where rowed > (select min (rowid) from table_name b where

A.key_values = B.key_values); SQL query to delete duplicate records based on more than one column

delete from <table_name> where rowid not in ( select min(rowid)

from <Table_name> group by column1..,column2,...column3..)

Another approach to delete duplicate records from table

This method is usually faster. However, remember to recreate all indexes,

constraints, triggers, etc. on the table when done.

SQL> create table table_name2 as select distinct * from table_name1;SQL> drop table table_name1;SQL> rename table_name2 to table_name1;

To display records randomly like 10% of records from table by using below querySelect * from emp sample(10);Note: Sample works after oracle 8i and has to apply to single query

One solution is to use the MINUS operation, to display rows 5 to 7, construct

a query like this:

SELECT *FROM tableXWHERE rowid in ( SELECT rowid FROM tableX WHERE rownum <= 7 MINUS SELECT rowid FROM tableX WHERE rownum < 5);

Page 5: Basic Understand Document

Another approach to retrieve rows from X to Y

SELECT * FROM ( SELECT ename, rownum rn FROM emp WHERE rownum < 101) WHERE RN between 91 and 100;

CREATE TABLE EMP_MASTER(EMP_NBR NUMBER(10) NOT NULL PRIMARY KEY,EMP_NAME VARCHAR2(20 CHAR),MGR_NBR NUMBER(10) NULL)/

INSERT INTO EMP_MASTER VALUES (1, ‘DON’, 5);INSERT INTO EMP_MASTER VALUES (2, ‘HARI’, 5);INSERT INTO EMP_MASTER VALUES (3, ‘RAMESH’, 5);INSERT INTO EMP_MASTER VALUES (4, ‘JOE’, 5);INSERT INTO EMP_MASTER VALUES (5, ‘DENNIS’, NULL);INSERT INTO EMP_MASTER VALUES (6, ‘NIMISH’, 5);INSERT INTO EMP_MASTER VALUES (7, ‘JESSIE’, 5);INSERT INTO EMP_MASTER VALUES (8, ‘KEN’, 5);INSERT INTO EMP_MASTER VALUES (9, ‘AMBER’, 5);INSERT INTO EMP_MASTER VALUES (10, ‘JIM’, 5);COMMIT/

Resulting in:

EMP_NBR

EMP_NAME

MGR_NBR

1 DON 52 HARI 53 RAMESH 54 JOE 55 DENNIS NULL6 NIMISH 57 JESSIE 5

Page 6: Basic Understand Document

8 KEN 59 AMBER 510 JIM 5

Now, the aim is to find all those employees who are not managers. Let’s see how we can achieve that by using the “NOT IN” vs the “NOT EXISTS” clause.

NOT IN

SQL> select count(*) from emp_master where emp_nbr not in ( select mgr_nbr from emp_master );COUNT(*)———-0

This means that everyone is a manager…hmmm, I wonder whether anything ever gets done in that case

NOT EXISTS

SQL> select count(*) from emp_master T1 where not exists ( select 1 from emp_master T2 where t2.mgr_nbr = t1.emp_nbr );

COUNT(*)———-9

Now there are 9 people who are not managers. So, you can clearly see the difference that NULL values make and since NULL != NULL in SQL, the NOT IN clause does not return any records back. (in MS SQL Server, depending upon the ANSI NULLS setting, the behavior can be altered but this post only talks about the behavior that is same in Oracle, DB2 LUW and MS SQL Server).

Performance implications:

When using “NOT IN”, the query performs nested full table scans, whereas for “NOT EXISTS”, query can use an index within the sub-query.

Fetch all the employees under manager directly/indirectly

empId empName empManagerId1 A2 B 13 C 24 D 25 E 4

Page 7: Basic Understand Document

Now the question is that what should be the single line query or best solution if i want to get all employess under a perticular manager ?For example; Employees under 'A' are (B,C,D,E)    //(C,D,E are also indirectly under A)Emplloyess under 'B' are (C,D & E; E is also under B as his because his managwer 'D' is himself under 'B')

SELECT E1.empNameAS Employee, E2.empNameAS Manager FROM tbl_employees AS E1 INNER JOIN tbl_employees AS E2 ON E1.ManagerID = E2.EmployeeID

There are three algorithms are used in Telecom network:

1. A3 for Authentication2. A5 for Encryption3. A8 for key generation

Association, Aggregation, Composition, Abstraction, Generalization, Realization,

Dependency

These terms signify the relationships between classes. These are the building blocks of object oriented programming and very basic stuff. But still for some, these terms look like Latin and

Greek. Just wanted to refresh these terms and explain in simpler terms.

Association

Association is a relationship between two objects. In other words, association defines the multiplicity between objects. You may be aware of one-to-one, one-to-many, many-to-one,

many-to-many all these words define an association between objects. Aggregation is a special form of association. Composition is a special form of aggregation.

Example: A Student and a Faculty are having an association.

Page 8: Basic Understand Document

Aggregation

Aggregation is a special case of association. A directional association between objects. When an object ‘has-a’ another object, then you have got an aggregation between them. Direction between

them specified which object contains the other object. Aggregation is also called a “Has-a” relationship.

Composition

Composition is a special case of aggregation. In a more specific manner, a restricted aggregation is called composition. When an object contains the other object, if the contained object cannot

exist without the existence of container object, then it is called composition.

Example: A class contains students. A student cannot exist without a class. There exists composition between class and students.

Difference between aggregation and composition

Composition is more restrictive. When there is a composition between two objects, the composed object cannot exist without the other object. This restriction is not there in

aggregation. Though one object can contain the other object, there is no condition that the composed object must exist. The existence of the composed object is entirely optional. In both aggregation and composition, direction is must. The direction specifies, which object contains

the other object.

Example: A Library contains students and books. Relationship between library and student is aggregation. Relationship between library and book is composition. A student can exist without a

library and therefore it is aggregation. A book cannot exist without a library and therefore its a composition. For easy understanding I am picking this example. Don’t go deeper into example

and justify relationships!

Abstraction

Abstraction is specifying the framework and hiding the implementation level information. Concreteness will be built on top of the abstraction. It gives you a blueprint to follow to while

implementing the details. Abstraction reduces the complexity by hiding low level details.

Example: A wire frame model of a car.

Page 9: Basic Understand Document

Generalization

Generalization uses a “is-a” relationship from a specialization to the generalization class. Common structure and behaviour are used from the specializtion to the generalized class. At a

very broader level you can understand this as inheritance. Why I take the term inheritance is, you can relate this term very well. Generalization is also called a “Is-a” relationship.

Example: Consider there exists a class named Person. A student is a person. A faculty is a person. Therefore here the relationship between student and person, similarly faculty and person

is generalization.

Realization

Realization is a relationship between the blueprint class and the object containing its respective implementation level details. This object is said to realize the blueprint class. In other words, you

can understand this as the relationship between the interface and the implementing class.

Example: A particular model of a car ‘GTB Fiorano’ that implements the blueprint of a car realizes the abstraction.

Dependency

Change in structure or behaviour of a class affects the other related class, then there is a dependency between those two classes. It need not be the same vice-versa. When one class

contains the other class it this happens.

Example: Relationship between shape and circle is dependency.

Mobile Station ISDN Number (MSISDN)

Page 10: Basic Understand Document

The MSISDN is a number which uniquely identifies a mobile telephone subscription in the public switched

telephone network numbering plan. According to the CCITT recommendations, the mobile telephone

number or catalogue number to be dialled is composed in the following way:

MSISDN = CC + NDC + SN

CC = Country Code

NDC = National Destination Code

SN = Subscriber Number

A National Destination Code is allocated to each GSM PLMN. In some countries, more than one NDC

may be required for each GSM PLMN. The international MSISDN number may be of variable length. The

maximum length shall be 15 digits, prefixes not included.

Each subscription is connected to one Home Location Register (HLR).

The length of the MSISDN depends on the structure and numbering plan of each operator, as an

application of CCITT recommendation E.164.

The following is an example of dialling a GSM subscriber.

International Mobile Subscriber Identity (IMSI)

The IMSI is the information which uniquely identifies a subscriber in a

GSM/PLMN.

For a correct identification over the radio path and through the GSM PLMN

network, a specific identity is allocated to each subscriber. This identity is

called the International Mobile Subscriber Identity (IMSI) and is used for all

signalling in the PLMN. It will be stored in the Subscriber Identity Module

Page 11: Basic Understand Document

(SIM), as well as in the Home Location Register (HLR) and in the serving

Visitor Location Register (VLR).

The IMSI consists of three different parts:IMSI = MCC + MNC + MSIN

MCC = Mobile Country Code (3 digits)

MNC = Mobile Network Code (2 digits)

MSIN = Mobile Subscriber Identification Number (max 10 digits)

According to the GSM recommendations, the IMSI will have a length of

maximum 15 digits.

All network–related subscriber information is connected to the IMSI. See also

Figure 56.

Mobile Station Roaming Number (MSRN)

HLR knows in what MSC/VLR Service Area the subscriber is located. In order

to provide a temporary number to be used for routing, the HLR requests the

current MSC/VLR to allocate and return a Mobile Station Roaming Number

(MSRN) for the called subscriber, see Figure 56.

At reception of the MSRN, HLR sends it to the GMSC, which can now route

the call to the MSC/VLR exchange where the called subscriber is currently

registered.

The interrogation call routing function (request for an MSRN) is part of the

Mobile Application Part (MAP). All data exchanged between the GMSC - HLR

- MSC/VLR for the purpose of interrogation is sent over the No. 7 signalling

network.

Page 12: Basic Understand Document

The Mobile Station Roaming Number (MSRN), according to the GSM

recommendations, consists of three parts:

MSRN = CC + NDC + SN

CC = Country Code

NDC = National Destination Code

SN = Subscriber Number

Note: In this case, SN is the address to the serving MSC.

If You Like this than become our Friend on Facebook

Temporary Mobile Subscriber Identity (TMSI)The TMSI is a temporary number used instead of the IMSI to identify an MS. It raises the subscriber’s

confidentiality and is known within the serving MSC/VLR-area and changed at certain events or time

intervals. The structure of the TMSI may be chosen by each administration but should have a maximum

length of four octets (8 digits).

International Mobile station Equipment Identity (IMEI)

The IMEI is used for equipment identification. An IMEI uniquely identifies a mobile station as a piece or

assembly of equipment. (See IMEI, chapter 5.)

IMEI = TAC + FAC + SNR + sp

TAC = Type Approval Code (6 digits), determined by a central GSM body

FAC = Final Assembly Code (2 digits), identifies the manufacturer

SNR = Serial Number (6 digits), an individual serial number of six digits uniquely identifying all equipment

within each TAC and FAC

sp = spare for future use (1 digit)

According to the GSM specification, IMEI has the length of 15 digits.

Location Area Identity (LAI)

LAI is used for location updating of mobile subscribers.

LAI = MCC + MNC + LAC

Page 13: Basic Understand Document

MCC = Mobile Country Code (3 digits), identifies the country. It follows the same numbering plan as MCC

in IMSI.

MNC = Mobile Network Code (2 digits), identifies the GSM/PLMN in that country and follows the same

numbering plan as the MNC in IMSI.

LAC = Location Area Code, identifies a location area within a GSM PLMN network. The maximum length

of LAC is 16 bits, enabling 65 536 different location areas to be defined in one GSM PLMN.

Cell Global Identity (CGI)

CGI is used for cell identification within the GSM network. This is done by adding a Cell Identity (CI) to the

location area identity.

CGI = MCC + MNC + LAC + CI

CI = Cell Identity, identifies a cell within a location area, maximum 16 bits

Base Station Identity Code (BSIC)

BSIC allows a mobile station to distinguish between different neighboring base stations.

BSIC = NCC + BCC

NCC = Network Colour Code (3 bits), identifies the GSM PLMN.

Note that it does not uniquely identify the operator. NCC is primarily used to distinguish between

operators on each side of border.

BCC = Base Station Colour Code (3 bits), identifies the Base Station to help distinguish between BTS

using the same BCCH frequencies

Location Number (LN)

Location Number is a number related to a certain geographical area, as specified by the network operator

by ”tying” the location numbers to cells, location areas, or MSC/VLR service areas.

The Location Number is used to implement features like Regional /Local subscription and Geographical

differentiated charging.

What packages (if any) has Oracle provided for use by developers? Expected answer: Oracle provides the DBMS_ series of packages. There are many which developers should be aware of such as DBMS_SQL,

Page 14: Basic Understand Document

DBMS_PIPE, DBMS_TRANSACTION, DBMS_LOCK, DBMS_ALERT, DBMS_OUTPUT, DBMS_JOB, DBMS_UTILITY, DBMS_DDL, UTL_FILE.

Find out nth highest salary from emp table

SELECT DISTINCT (a.sal) FROM EMP A WHERE &N = (SELECT COUNT (DISTINCT (b.sal)) FROM EMP B

WHERE a.sal<=b.sal);

What is the difference between Comparator and comparable interfaces?

Comparable is part of java.lang and Comparator is part of java.util Comparable is used to sort set of data based on natural order, but Comparator used to sort

set of data based on multiple fields, and can be used with utility methods

If implements Comparable interface needs to override comparTO(Object o) method, in case of Comparator needs to override compara(Object o1, Object o2) method

Page 15: Basic Understand Document

In Comparable case compares same class instances, where as in case of Comparator it will not compare instance’s of same class instead compares one class instance with another class instance