Nothing Special   »   [go: up one dir, main page]

Unit 2 Java Programmingg Question Answer

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 25

SHREERAMCHANDRACOLLEGEOF ENGINEERING, LONIKAND,PUNE412216

UNIT2
SubjectName:Java Programming ModelAnswer SubjectCode:22412

1 Name the wrapper class methods for the following: 2m


(i) To convert string objects to primitive int.
(ii) To convert primitive int to string objects. (Summer 19)
Ans: (i) To convert string objects to primitive int:
String str=”5”;

int value = Integer.parseInt(str);


(ii) To convert primitive int to string objects:
int value=5;
String str=Integer.toString(value);
2 Explain the types of constructors in Java with suitable example. (summer 4m
19,winter 19 ,Summer 23)
(Note: Any two types shall be considered)
Ans: Constructors are used to initialize an object as soon as it is created. Explanation
Every time an object is created using the ‘new’ keyword, a of
constructor is invoked. If no constructor is defined in a class, java the two
compiler creates a default constructor. Constructors are similar to types of
methods but with to differences, constructor has the same name as construc
that of the class and it does not return any value. tors 2M
The types of constructors are: Example
1. Default constructor 2M
2. Constructor with no arguments
3. Parameterized constructor
4. Copy constructor
1. Default constructor: Java automatically creates default constructor
if there is no default or parameterized constructor written by user.
Default constructor in Java initializes member data variable to default
values (numeric values are initialized as 0, Boolean is initialized as
false and references are initialized as null).
class test1 {
int i;
boolean b;
byte bt;
float ft;
String s;
public static void main(String args[]) {
test1 t = new test1(); // default constructor is called.
System.out.println(t.i);
System.out.println(t.s);
System.out.println(t.b);
System.out.println(t.bt);
System.out.println(t.ft);
}
}
2. Constructor with no arguments: Such constructors does not have
any parameters. All the objects created using this type of constructors
has the same values for its datamembers.

Prof.Neha Pavitrakar ShreeRamchandraCollegeofEngineering Page1


SHREERAMCHANDRACOLLEGEOF ENGINEERING, LONIKAND,PUNE412216
Eg:
class Student {
int roll_no;
String name;
Student() {
roll_no = 50;
name="ABC";
}
void display() {
System.out.println("Roll no is: "+roll_no);
System.out.println("Name is : "+name);
}
public static void main(String a[]) {
Student s = new Student();
s.display();
}
}
3. Parametrized constructor: Such constructor consists of parameters.
Such constructors can be used to create different objects with
datamembers having different values.
class Student {
int roll_no;
String name;
Student(int r, String n) {
roll_no = r;
name=n;
}
void display() {
System.out.println("Roll no is: "+roll_no);
System.out.println("Name is : "+name);
}
public static void main(String a[]) {
Student s = new Student(20,"ABC");
s.display();
}
}
4. Copy Constructor : A copy constructor is a constructor that creates
a new object using an existing object of the same class and initializes
each instance variable of newly created object with corresponding
instance variables of the existing object passed as argument. This
constructor takes a single argument whose type is that of the class
containing the constructor.
class Rectangle
{
int length;
int breadth;
Rectangle(int l, int b)
{
length = l;
breadth= b;
}
//copy constructor
Rectangle(Rectangle obj)
{
Prof.Neha Pavitrakar ShreeRamchandraCollegeofEngineering Page2
SHREERAMCHANDRACOLLEGEOF ENGINEERING, LONIKAND,PUNE412216
length = obj.length;
breadth= obj.breadth;
}
public static void main(String[] args)
{
Rectangle r1= new Rectangle(5,6);
Rectangle r2= new Rectangle(r1);
System.out.println("Area of First Rectangle : "+
(r1.length*r1.breadth));
System .out.println("Area of First Second Rectangle : "+
(r1.length*r1.breadth));
}
}

3 Define a class student with int id and string name as data members and a 4m
method void SetData ( ). Accept and display the data for five students.
(summer 2019)
Ans: import java.io.*;
class student
{
int id;
String name;
BufferedReader br = new BufferedReader(new
InputStreamReader(System.in));
void SetData()
{
try
{
System.out.println("enter id and name for student");
id=Integer.parseInt(br.readLine());
name=br.readLine();
}
catch(Exception ex)
{}
}
void display()
{
System.out.println("The id is " + id + " and the name is "+ name);
}
public static void main(String are[])
{
student[] arr;
arr = new student[5];
int i;
for(i=0;i<5;i++)
{
arr[i] = new student();
}
for(i=0;i<5;i++)
{
arr[i].SetData();
}
for(i=0;i<5;i++)
{
Prof.Neha Pavitrakar ShreeRamchandraCollegeofEngineering Page3
SHREERAMCHANDRACOLLEGEOF ENGINEERING, LONIKAND,PUNE412216
arr[i].display();
}
}
}

4 Describe the use of any methods of vector class with their syntax. 6m
(Note: Any method other than this but in vector class shall be
considered for answer). (summer 19)
Ans:  boolean add(Object obj)-Appends the specified element to the
end of this Vector.
 Boolean add(int index,Object obj)-Inserts the specified element at
the specified position in this Vector.
 void addElement(Object obj)-Adds the specified component to
the end of this vector, increasing its size by one.
 int capacity()-Returns the current capacity of this vector.
 void clear()-Removes all of the elements from this vector.
 Object clone()-Returns a clone of this vector.
 boolean contains(Object elem)-Tests if the specified object is a
component in this vector.
 void copyInto(Object[] anArray)-Copies the components of this
vector into the specified array.
 Object firstElement()-Returns the first component (the item at
index 0) of this vector.
 Object elementAt(int index)-Returns the component at the
specified index.
 int indexOf(Object elem)-Searches for the first occurence of the
given argument, testing for equality using the equals method.
 Object lastElement()-Returns the last component of the vector.
 Object insertElementAt(Object obj,int index)-Inserts the specified
object as a component in this vector at the specified index.
 Object remove(int index)-Removes the element at the specified
position in this vector.
 void removeAllElements()-Removes all components from this
svector and sets its size to zero

5 Define Constructor. List its types. (winter 19,winter 22) 2M


Ans: Constructor: A constructor is a special member which initializes an object
immediately upon creation. It has the same name as class name in which it
resides and it is syntactically similar to any method. When a constructor is not
defined, java executes a default constructor which initializes all numeric
members to zero and other types to null or spaces. Once defined, constructor is
automatically called immediately after the object is created before new operator
completes.
Types of constructors:
1. Default constructor
2. Parameterized constructor
3. Copy constructor

6 Differentiate between String and String Buffer. (winter 19,Summer 4M


22,Summer 23)

Prof.Neha Pavitrakar ShreeRamchandraCollegeofEngineering Page4


SHREERAMCHANDRACOLLEGEOF ENGINEERING, LONIKAND,PUNE412216
Ans:

7 Differentiate between array and vector. (winter19,winter 22,summer 22) 4m


Ans:

Prof.Neha Pavitrakar ShreeRamchandraCollegeofEngineering Page5


SHREERAMCHANDRACOLLEGEOF ENGINEERING, LONIKAND,PUNE412216

8 ) List any four methods of string class and state the use of each. (Winter 4M(
19,Summer 22)
Ans: The java.lang.String class provides a lot of methods to work on
string. By the help of these methods,
We can perform operations on string such as trimming,
concatenating, converting, comparing, replacing strings etc.
1) to Lowercase (): Converts all of the characters in this String
to lower case.
Syntax: s1.toLowerCase()
Example: String s="Sachin";
System.out.println(s.toLowerCase());
Output: sachin
2)to Uppercase():Converts all of the characters in this String to
upper case
Syntax: s1.toUpperCase()
Example:
String s="Sachin";
System.out.println(s.toUpperCase());
Output: SACHIN
3) trim (): Returns a copy of the string, with leading and trailing
whitespace omitted.
Prof.Neha Pavitrakar ShreeRamchandraCollegeofEngineering Page6
SHREERAMCHANDRACOLLEGEOF ENGINEERING, LONIKAND,PUNE412216
Syntax: s1.trim()
Example:
String s=" Sachin ";
System.out.println(s.trim());
Output:Sachin
4) replace ():Returns a new string resulting from replacing all
occurrences of old Char in this string with new Char.
Syntax: s1.replace(‘x’,’y’)
Example:
String s1="Java is a programming language. Java is a platform.";
String s2=s1.replace("Java","Kava"); //replaces all occurrences
of "Java" to "Kava"
System.out.println(s2);
Output: Kava is a programming language. Kava is a platform
9 Write a program to create a vector with five elements as (5,15, 25, 35, 45). 6m
st
Insert new element at 2nd position. Remove 1 and 4th element from
vector. (winter 19)
Ans: import java.util.*;
class VectorDemo
{
public static void main(String[] args)
{
Vector v = new Vector();
v.addElement(new Integer(5));
v.addElement(new Integer(15));
v.addElement(new Integer(25));
v.addElement(new Integer(35));
v.addElement(new Integer(45));
System.out.println("Original array elements are
");
for(int i=0;i<v.size();i++)
{
System.out.println(v.elementAt(i));
}
v.insertElementAt(new Integer(20),1); // insert
new element at 2nd position
v.removeElementAt(0);
//remove first element
v.removeElementAt(3);
//remove fourth element
System.out.println("Array elements after insert
and remove operation ");
for(int i=0;i<v.size();i++)
{
System.out.println(v.elementAt(i));
}}}

10 Enlist access specifiers in Java (winter 22,Summer 23) 2m


Ans: The access specifiers in java specify accessibility (scope) of a data member,
method, constructor or class. There are 5 types of java access specifier:
 public
 private
 default (Friendly)

Prof.Neha Pavitrakar ShreeRamchandraCollegeofEngineering Page7


SHREERAMCHANDRACOLLEGEOF ENGINEERING, LONIKAND,PUNE412216
 protected
11 Define a class employee with data members 'empid , name and salary. 4m
Accept data for three objects and display it (winter 22)
Ans: class employee
{
int empid;
String name;
double salary;
void getdata()
{
BufferedReader obj = new BufferedReader (new
InputStreamReader(System.in));
System.out.print("Enter Emp number : ");
empid=Integer.parseInt(obj.readLine());
System.out.print("Enter Emp Name : ");
name=obj.readLine();
System.out.print("Enter Emp Salary : ");
salary=Double.parseDouble(obj.readLine());
}
void show()
{
System.out.println("Emp ID : " + empid);
System.out.println(“Name : " + name);
System.out.println(“Salary : " + salary);
}
}
classEmpDetails
{
public static void main(String args[])
{
employee e[] = new employee[3];
for(inti=0; i<3; i++)
{
e[i] = new employee(); e[i].getdata();
}
System.out.println(" Employee Details are : ");
for(inti=0; i<3; i++)
e[i].show();
}
}

12 Write a program to add 2 integer, 2 string and 2 float values is a vector. 4m


Remove the element specified by the user and display the list. (winter 22)
Ans: import java.io.*;
import java.lang.*;
import java.util.*;
class vector2
{
public static void main(String args[])
{
vector v=new vector();
Integer s1=new Integer(1);
Integer s2=new Integer(2);

Prof.Neha Pavitrakar ShreeRamchandraCollegeofEngineering Page8


SHREERAMCHANDRACOLLEGEOF ENGINEERING, LONIKAND,PUNE412216
String s3=new String("fy");
String s4=new String("sy");
Float s7=new Float(1.1f);
Float s8=new Float(1.2f);
v.addElement(s1);
v.addElement(s2);
v.addElement(s3);
v.addElement(s4);
v.addElement(s7);
v.addElement(s8);
System.out.println(v);
v.removeElement(s2);
v.removeElementAt(4);
System.out.println(v);
}
}
13 ) Write a program to check whether the string provided by the user is 6m
palindrome or not. (winter 22)
Ans: import java.lang.*;
import java.io.*;
import java.util.*;
class palindrome
{
public static void main(String arg[ ]) throws IOException
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter String:");
String word=br.readLine( );
int len=word.length( )-1;
int l=0;
int flag=1;
int r=len;
while(l<=r)
{
if(word.charAt(l)==word.charAt(r))
{
l++;
r--;
}
else
{
flag=0;
break;
}
}
if(flag==1)
{
System.out.println("palindrome");
}
else
{
System.out.println("not palindrome");
}
}
Prof.Neha Pavitrakar ShreeRamchandraCollegeofEngineering Page9
SHREERAMCHANDRACOLLEGEOF ENGINEERING, LONIKAND,PUNE412216
}

14 Define array. List its types. (Winter 19) 2m


Ans: An array is a homogeneous data type where it can hold only objects of one data
type.
Types of Array:
1)One-Dimensional
2)Two-Dimensional
15 Explain any four visibility controls in Java.4m (summer 22)
Ans:

1. Default Access Modifier


When no access modifier is specified for a class, method, or data member – It
is said to be having the default access modifier by default. The data members,
classes, or methods that are not declared using any access modifiers i.e.
having default access modifiers are accessible only within the same package.

package p1;

// Class Geek is having Defauslt access modifier


class Geek
{
void display()
{
System.out.println("Hello World!");
}
}

2. Private Access Modifier


The private access modifier is specified using the keyword private. The
methods or data members declared as private are accessible only within the
class in which they are declared.

package p1;

class A
{
private void display()
{
System.out.println("GeeksforGeeks");
}

Prof.Neha Pavitrakar ShreeRamchandraCollegeofEngineering Page1


0
SHREERAMCHANDRACOLLEGEOF ENGINEERING, LONIKAND,PUNE412216
}

class B
{
public static void main(String args[])
{
A obj = new A();
// Trying to access private method
// of another class
obj.display();
}
}
3. Protected Access Modifier
The protected access modifier is specified using the keyword protected.
The methods or data members declared as protected are accessible within the
same package or subclasses in different packages.
package p1;

// Class A
public class A
{
protected void display()
{
System.out.println("GeeksforGeeks");
}
}
package p2;
import p1.*; // importing all classes in package p1

// Class B is subclass of A
class B extends A
{
public static void main(String args[])
{
B obj = new B();
obj.display();
}

4.Public Access modifier


The public access modifier is specified using the keyword public.
The public access modifier has the widest scope among all other access
modifiers.
Classes, methods, or data members that are declared as public are accessible
from everywhere in the program. There is no restriction on the scope of public
data members.
package p1;
public class A
{
public void display()
{
System.out.println("GeeksforGeeks");
}
Prof.Neha Pavitrakar ShreeRamchandraCollegeofEngineering Page1
1
SHREERAMCHANDRACOLLEGEOF ENGINEERING, LONIKAND,PUNE412216
}
package p2;
import p1.*;
class B {
public static void main(String args[])
{
A obj = new A();
obj.display();
}}
16 Give use of garbage collection in java?(summer 23) 2m
Ans: Garbage collection in Java is the automated process of deleting code that's
no longer needed or used. This automatically frees up memory space and
ideally makes coding Java apps easier for developers. Java applications are
compiled into bytecode that may be executed by a JVM.
17 Explain four methods of vector class with example? (Summer 23) 4m
Ans:
1 Java Vector add() Method

The add() is a Java Vector class method which is used to insert the specified
element in the given Vector. There are two different types of Java add() method
which can be differentiated depending on its parameter. These are:

1.Java Vector add(int index, E element) Method

2.Java Vector add(E e) Method

Example:

import java.util.Vector;
public class VectorAddExample1 {
public static void main(String args[]) {
//Create an empty Vector with an initial capacity of 5
Vector<String> vc = new Vector<>(4);
//Add elements in the vector by using add() method
vc.add("A");
vc.add("B");
vc.add("C");
vc.add("D");
vc.add("E");
//Print all the elements of a Vector
System.out.println("--Elements of Vector are--");
for (String str : vc) {
System.out.println("Alphabet= " +str);
} } }

Prof.Neha Pavitrakar ShreeRamchandraCollegeofEngineering Page1


2
SHREERAMCHANDRACOLLEGEOF ENGINEERING, LONIKAND,PUNE412216
Output:
--Elements of Vector are--
Alphabet= A
Alphabet= B
Alphabet= C
Alphabet= D
Alphabet= E

2 Java Vector clear() Method

The clear() method of Java Vector class is used to remove all of the elements
from the vector which is in use.

Syntax:

Following is the declaration of clear() method:

Public void clear()

Example:

import java.util.Vector;
public class VectorClearExample1 {
public static void main(String arg[]) {
//Create an empty Vector
Vector<String> vc = new Vector<>();
//Add elements in the vector by using add() method
vc.add("A");
vc.add("B");
vc.add("C");
//Print the size of vector
System.out.println("Size of Vector before clear() method: "+vc.size()
);
//Clear the vector
vc.clear();
System.out.println("Size of Vector after clear() method: "+vc.size());
}
}

Output:

Size of Vector before clear() method: 3


Size of Vector after clear() method: 0

Prof.Neha Pavitrakar ShreeRamchandraCollegeofEngineering Page1


3
SHREERAMCHANDRACOLLEGEOF ENGINEERING, LONIKAND,PUNE412216

3 Java Vector get() Method


The get() method of Java Vector class is used to get the element at the specified
position in the vector.

Syntax

Following is the declaration of get() method:

public E get(int index)


Example:
import java.util.*;
public class VectorGetExample1 {
public static void main(String arg[]) {
//Create an empty vector
Vector<Integer> vec = new Vector<>();
//Add element in the vector
vec.add(1);
vec.add(2);
vec.add(3);
vec.add(4);
vec.add(5);
//Get the element at specified index
System.out.println("Element at index 1 is = "+vec.get(1));
System.out.println("Element at index 3 is = "+vec.get(3));
}
}

Output:

Element at index 1 is = 2
Element at index 3 is = 4
4 Java Vector capacity() Method

The capacity() method of Java Vector class is used to get the current capacity
of the vector which is in use.

Syntax:

Following is the declaration of capacity() method:

Public int capacity()


Prof.Neha Pavitrakar ShreeRamchandraCollegeofEngineering Page1
4
SHREERAMCHANDRACOLLEGEOF ENGINEERING, LONIKAND,PUNE412216
Example :
import java.util.Vector;
public class VectorCapacityExample1 {
public static void main(String arg[]) {
//Create an empty Vector with initial capacity of 5
Vector<Integer> vecObject = new Vector<Integer>(5);
//Add values in the vector
vecObject.add(3);
vecObject.add(5);
vecObject.add(2);
vecObject.add(4);
vecObject.add(1);
System.out.println("Current capacity of Vector is: "+vecObject.capacity()
);
}
Output:
Current capacity of Vector is: 5
18 Write a program to copy all elements of one array into another 6m
array(Summer 23)
Ans:
public class CopyArray {
public static void main(String[] args) {
//Initialize array
int [] arr1 = new int [] {1, 2, 3, 4, 5};
//Create another array arr2 with size of arr1
int arr2[] = new int[arr1.length];
//Copying all elements of one array into another
for (int i = 0; i < arr1.length; i++) {
arr2[i] = arr1[i];
}
//Displaying elements of array arr1
System.out.println("Elements of original array: ");
for (int i = 0; i < arr1.length; i++) {
System.out.print(arr1[i] + " ");
}
System.out.println();

//Displaying elements of array arr2


Prof.Neha Pavitrakar ShreeRamchandraCollegeofEngineering Page1
5
SHREERAMCHANDRACOLLEGEOF ENGINEERING, LONIKAND,PUNE412216
System.out.println("Elements of new array: ");
for (int i = 0; i < arr2.length; i++) {
System.out.print(arr2[i] + " ");
}
}

Output:

Elements of original array


12345
Elements of new array:
12345

Prof.Neha Pavitrakar ShreeRamchandraCollegeofEngineering Page1


6
SHREERAMCHANDRACOLLEGEOF ENGINEERING, LONIKAND,PUNE412216
UNIT2

e Draw structural diagram of fiber optic cable and write its functions 2
M
2 M for
diagram
and 2 M
f
2 M for
diagram
and 2 M
for
functions

Fig. Structural diagram for Fibre Optic Cable


Functions of Optical Cable:
1. Single-mode fibers - Used to transmit one signal per fiber (used in telephones
and cable TV)
2. Multi-mode fibers - Used to transmit many signals per fiber (used in computer
networks, local area networks)

f What advantages does TDM have over FDM in a circuit switched network? 4M
 In TDM, each signal uses all of the bandwidth some of the time, while for
FDM, each signal uses a small portion of the bandwidth all of the time. consider
 TDM uses the entire frequency range but dynamically allocates time, certain 4 points
jobs might require less or more time, which TDM can offer but FDM is for 4 M
unable to as it cannot change the width of the allocated frequency.
 TDM provides much better flexibility compared to FDM.
 TDM offers efficient utilization of bandwidth
 Low interference of signal and minimizes cross talk

Prof.GulnajSayyad ShreeRamchandraCollegeofEngineering Page17


SHREERAMCHANDRACOLLEGEOF ENGINEERING, LONIKAND,PUNE412216
UNIT2

g Differentiate between FDM and TDM 4M

Sr.No FDM TDM 1M for


each
1 FDM divides the channel into TDM divides and allocates
differenc
two certain
e
or more frequency ranges that time periods to each
do channel in an
not overlap alternating manner
2 Frequency is shared Times scale is shared
3 Used with Analog signals Used with both Digital
signals and
analog signals
4 Interference is high Interference is Low or
negligible
5 Utilization is Ineffective Efficiently used

h Why is circuit switching preferred over packet switching in voice 6M


communication?
Any six
Switching is a mechanism by which data/information sent from source towards points 1
destination which are not directly connected. Networks have interconnecting devices, M each
which receives data from directly connected sources, stores data, analyse it and then
forwards to the next interconnecting device closest to the destination.

Switching can be categorized as:

 Circuit switching

 Packet switching

 Message switching

Circuit switching is preferred over packet switching in voice communication

because:

In circuit switching, a dedicated path is established between sender and

receiver which is maintained for entire duration of conversation.

 It provides continuous and guaranteed delivery of data.

 During the data transfer phase, no addressing is needed.

 Delays are small.

Prof.GulnajSayyad ShreeRamchandraCollegeofEngineering Page18


SHREERAMCHANDRACOLLEGEOF ENGINEERING, LONIKAND,PUNE412216
UNIT2
 It uses connection oriented service.

 Message received in order to the destination


i Draw and explain fiber optic cable. 4M
2 M Labelled
Diagram,2 M
explanation

Fiber optic cable:

 A fiber-optic cable is made up of glass or plastic.

 It transmits signals in the form of light.

 The outer jacket is made up of PVC or Teflon.

 Kevlar strands are placed inside the jacket to strengthen the cable.

 Below the Kevlar strands, there is another plastic coating which acts as
acushion.

 The fiber is at the center of the cable, and it consists of cladding and
glass core.

 The density of the cladding is less than that of the core .

 Optical fibers use the principle of ‘reflection’ to pass light through a


channel.

Prof.GulnajSayyad ShreeRamchandraCollegeofEngineering Page19


SHREERAMCHANDRACOLLEGEOF ENGINEERING, LONIKAND,PUNE412216
UNIT2

j State the two advantages and disadvantages of unguided media 4M


2 M advantages
Advantages: 1 mark for each
advantage 2 M
1 .Use for long distance communication. Disadvantages
1mark for each
2. High speed data transmission. disadvantage
3. Many receiver stations can receive signals from same sender station

Disadvantages :

1..Radio waves travel through Lowest portion of atmosphere which can have lot of
noise and interfering signals

2. Radio wave communication through unguided media is an insecure


communication. 3.Radio wave propagation is susceptible to weather effects like
rain, thunder and storm etc.

k Describe Multiplexing techniques 4M


2 M each
Multiplexing is a technique by which different analog and digital streams of technique
transmission can be simultaneously processed over a shared link. Multiplexing explanation
divides the high capacity medium into low capacity logical medium which is then
shared by different streams. Communication is possible over the air (radio
frequency), using a physical media (cable), and light (optical fiber). All mediums
are capable of multiplexing. When multiple senders try to send over a single
medium, a device called Multiplexer divides the physical channel and allocates one
to each. On the other end of communication, a De-multiplexer receives data from a
single medium, identifies each, and sends to different receivers

Different multiplexing techniques are

1.Frequency Division multiplexing

2.Time division multiplexing

Frequency Division Multiplexing: When the carrier is frequency, FDM is used.


FDM is an analog technology. FDM divides the spectrum or carrier

Prof.GulnajSayyad ShreeRamchandraCollegeofEngineering Page20


SHREERAMCHANDRACOLLEGEOF ENGINEERING, LONIKAND,PUNE412216
UNIT2
bandwidth in logical channels and allocates one user to each channel. Each user can
use the channel frequency independently and has exclusive access of it. All channels
are divided in such a way that they do not overlap with each other. Channels are
separated by guard bands. Guard band is a frequency which is not used by either
channel

Time Division Multiplexing: TDM is applied primarily on digital signals but can be
applied on analog signals as well. In TDM the shared channel is divided among its
user by means of time slot. Each user can transmit data within the provided time slot
only. Digital signals are divided in frames, equivalent to time slot i.e. frame of an
optimal size which can be transmitted in given time slot. TDM works in
synchronized mode. Both ends, i.e. Multiplexer and Demultiplexer are timely
synchronized and both switch to next channel simultaneously

When channel A transmits its frame at one end, the De-multiplexer provides media
to channel A on the other end. As soon as the channel A’s time slot expires, this side
switches to channel B. On the other end, the De-multiplexer

works in a synchronized manner and provides media to channel B. Signals from


different channels travel the path in interleaved manner
l
Explain circuit switching networks with neat sketch.

Prof.GulnajSayyad ShreeRamchandraCollegeofEngineering Page21


SHREERAMCHANDRACOLLEGEOF ENGINEERING, LONIKAND,PUNE412216
UNIT2
1 M for
Circuit switching is a connection-oriented network switching technique. Here, a diagram. 3 M
dedicated route is established between the source and the destination and the entire for explaination
message is transferred through it

Phases of Circuit Switch Connection:

 Circuit Establishment: In this phase, a dedicated circuit is established from the


source to the destination through a number of intermediate switching centers. The
sender and receiver transmits communication signals to request and acknowledge
establishment of circuits.

 Data Transfer: Once the circuit has been established, data and voice are
transferred from the source to the destination. The dedicated connection remains as
long as the end parties communicate.

 Circuit Disconnection: When data transfer is complete, the connection is


relinquished. The disconnection is initiated by any one of the user. Disconnection
involves removal of all intermediate links from the sender to the receiver.

The diagram represents circuit established between two telephones connected by


circuit switched connection. The blue boxes represent the switching offices and
their connection with other switching offices. The black lines connecting the
switching offices represent the permanent link between the offices.

m Describe the principles of packet switching and circuit switching techniques 6M


with neat diagram.
Circuit
Circuit Switching: When two nodes communicate with each other over a dedicated switching-3M 1
communication path, it is called circuit switching. There 'is a need of pre-specified M –diagram,
route from which data will travels and no other data is permitted. In circuit 2M
switching, to transfer the data, circuit must be established so that the data transfer explanation:
can take place. Circuits can be permanent or temporary. Applications which use Packet
switching-3 M
circuit switching may have to go through three phases: 1.Establish a circuit
1M- diagram,
2M explanation
2.Transfer the data

3.Disconnect the circuit

Prof.GulnajSayyad ShreeRamchandraCollegeofEngineering Page22


SHREERAMCHANDRACOLLEGEOF ENGINEERING, LONIKAND,PUNE412216
UNIT2

Circuit switching was designed for voice applications. Telephone is the best suitable
example of circuit switching. Before a user can make a call, a virtual path between
callers and called is established over the network.

Packet Switching: The entire message is broken down into smaller chunks called
packets. The switching information is added in the header of each packet and
transmitted independently.

It is easier for intermediate networking devices to store small size packets and they
do not take much resource either on carrier path or in the internal memory of
switches

Packet switching enhances line efficiency as packets from multiple applications can
be multiplexed over the carrier. The internet uses packet switching technique.
Packet switching enables the user to differentiate data streams based on priorities.
Packets are stored and forwarded according to their priority to provide quality of
service.
n Draw a neat diagram of twisted pair cable and state its types. 4M

Prof.GulnajSayyad ShreeRamchandraCollegeofEngineering Page23


SHREERAMCHANDRACOLLEGEOF ENGINEERING, LONIKAND,PUNE412216
UNIT2
2 marks for
diagram &
2marks for
types

Fig.Twisted Pair cable

Twisted Pair Cables types :

1.Unshielded Twisted Pair Cables (UTP)

2.Shielded Twisted Pair Cables (STP)


o Compare packet switched and circuit switched network 4M
1 mark for each
point

Sr.N Packet Switching Circuit Switching


o.

1 In Packet switching directly In-circuit switching has there


data transfer takes place. are 3 phases:
i) Connection Establishment.
ii) Data Transfer.
iii) Connection Released.

2 In Packet switching, each data In-circuit switching, each data


unit just knows the final unit knows the entire path
destination address address which is provided by
intermediate path is decided the source.
by the routers.

3 In Packet switching, data is In-Circuit switching, data is


processed at all intermediate processed at the source system
nodes including the source only
system.

4 The delay between data units The delay between data units
in packet switching is not in circuit switching is
uniform. uniform.

5 Packet switching is less Circuit switching is more


reliable. reliable.

Prof.GulnajSayyad ShreeRamchandraCollegeofEngineering Page24


SHREERAMCHANDRACOLLEGEOF ENGINEERING, LONIKAND,PUNE412216
UNIT2
6 It is a store and forward It is not a store and forward
technique. technique.

7 No call setup is required in Call setup is required in


packet switching. circuit switching.

8 Packet switching is The circuit switching network


implemented at the datalink is implemented at the physical
layer and network layer layer.

Prof.GulnajSayyad ShreeRamchandraCollegeofEngineering Page25

You might also like