ETHERNET

Ethernet is the traditional technology for connecting wired local area networks (LANs), enabling devices to communicate with each other via a protocol — a set of rules or common network language.

Guided by Bipin Ajay , Founder of Tech Jitendra .

Ethernet is the traditional technology for connecting wired local area networks(LANs), enabling devices to communicate with each other via a protocol — a set of rules or common network language.

As a data-link layer protocol in the TCP/IPstack, Ethernet describes how network devices can format and transmit data packets so other devices on the same local or campus area network segment can recognize, receive and process them. An Ethernet cable is the physical, encased wiring over which the data travels.

Any device accessing a geographically localized network using a cable — i.e., with a wired rather than wireless connection — likely uses Ethernet — whether in a home, school or office setting. From businesses to gamers, diverse end users depend on the benefits of Ethernet connectivity, including reliability and security.

Compared to wireless LAN technology, Ethernet is typically less vulnerable to disruptions — whether from radio wave interference, physical barriers or bandwidth hogs. It can also offer a greater degree of network security and control than wireless technology, as devices must connect using physical cabling — making it difficult for outsiders to access network data or hijack bandwidth for unsanctioned devices.

How Ethernet works

The Institute of Electrical and Electronics Engineers Inc. (IEEE) specifies in the family of standards called IEEE 802.3 that the Ethernet protocol touches both Layer 1 — the physical layer — and Layer 2 — the data link layer — on the OSI network protocol model. Ethernet defines two units of transmission: packet and frame. The frame includes not just the payload of data being transmitted, but also:

  • the physical media access control (MAC) addresses of both the sender and receiver;
  • VLAN tagging and quality of serviceinformation; and
  • error correction information to detect transmission problems.

Each frame is wrapped in a packet that contains several bytes of information to establish the connection and mark where the frame starts.

Engineers at Xerox first developed Ethernet in the 1970s. Ethernet initially ran over coaxial cables, while a typical Ethernet LAN today uses special grades of twisted pair cables or fiber optic cabling. Early Ethernet connected multiple devices into network segments through hubs — Layer 1 devices responsible for transporting network data — using either a daisy chain or star topology.

Ethernet cable history image
Evolution of Ethernet

If two devices that share a hub try to transmit data at the same time, however, the packets can collide and create connectivity problems. To alleviate these digital traffic jams, the IEEE developed the Carrier Sense Multiple Access with Collision Detection (CSMA/CD) protocol, which allows devices to check whether a given line is in use before initiating new transmissions.

Later, Ethernet hubs largely gave way to network switches, their more sophisticated and modern counterparts. Because a hub cannot discriminate between points on a network segment, it can’t send data directly from point A to point B. Instead, whenever a network device sends a transmission via an input port, the hub copies the data and distributes it to all the available output ports.

In contrast, a switch intelligently sends any given port only the traffic intended for its devices rather than copies of any and all the transmissions on the network segment — improving security and efficiency.

Types of Ethernet cables

The IEEE 802.3 working group approved the first Ethernet standard in 1983. Since then, the technology has continued to evolve and embrace new media, higher transmission speeds and changes in frame content — e.g., 802.3ac to accommodate VLAN and priority tagging — and functional requirements — e.g., 802.3af to define Power over Ethernet(POE), which is crucial to most Wi-Fi and IP telephony deployments. Wi-Fi standards — IEEE 802.11a, b, g, n, ac and ax — define the equivalent of Ethernet for Wireless LANs.

Ethernet standard IEEE 802.3u ushered in 100BASE-T — also known as Fast Ethernet — with data transmission speeds of up to 100 megabits per second (Mbps). The term BASE-T indicates the use of twisted-pair cabling.

Gigabit Ethernet boasts speeds of 1,000 Mbps — 1 gigabit or 1 billion bits per second — 10-Gigabit Ethernet (GbE), up to 10 Gbps, and so on. Network engineers use 100BASE-T largely to connect end-user computers, printers and other devices; to manage servers and storage; and to achieve higher speeds for network backbone segments. Over time, the typical speed of each connection tends to increase.

Ethernet cables connect network devices to the appropriate routers or modems, with different cables working with different standards and speeds. The Category 5 (CAT5) cable supports traditional and 100BASE-T Ethernet, for example, while Category 5e (CAT5e) can handle Gigabit Ethernet and Category 6 (CAT6) works with 10 GbE.

Thanking you

Tech Jitendra

WHAT ARE THREADS IN JAVA ??

What are threads?

Guided by Bipin Ajay , Founder of Tech Jitendra

Nearly every operating system supports the concept of processes — independently running programs that are isolated from each other to some degree.

Threading is a facility to allow multiple activities to coexist within a single process. Most modern operating systems support threads, and the concept of threads has been around in various forms for many years. Java is the first mainstream programming language to explicitly include threading within the language itself, rather than treating threading as a facility of the underlying operating system.

Threads are sometimes referred to as lightweight processes. Like processes, threads are independent, concurrent paths of execution through a program, and each thread has its own stack, its own program counter, and its own local variables. However, threads within a process are less insulated from each other than separate processes are. They share memory, file handles, and other per-process state.

A process can support multiple threads, which appear to execute simultaneously and asynchronously to each other. Multiple threads within a process share the same memory address space, which means they have access to the same variables and objects, and they allocate objects from the same heap. While this makes it easy for threads to share information with each other, you must take care to ensure that they do not interfere with other threads in the same process.

The Java thread facility and API is deceptively simple. However, writing complex programs that use threading effectively is not quite as simple. Because multiple threads coexist in the same memory space and share the same variables, you must take care to ensure that your threads don’t interfere with each other.

Every Java program uses threads

Every Java program has at least one thread — the main thread. When a Java program starts, the JVM creates the main thread and calls the program’s main()method within that thread.

The JVM also creates other threads that are mostly invisible to you — for example, threads associated with garbage collection, object finalization, and other JVM housekeeping tasks. Other facilities create threads too, such as the AWT (Abstract Windowing Toolkit) or Swing UI toolkits, servlet containers, application servers, and RMI (Remote Method Invocation).

Why use threads?

There are many reasons to use threads in your Java programs. If you use Swing, servlets, RMI, or Enterprise JavaBeans (EJB) technology, you may already be using threads without realizing it.

Some of the reasons for using threads are that they can help to:

  • Make the UI more responsive
  • Take advantage of multiprocessor systems
  • Simplify modeling
  • Perform asynchronous or background processing

Thanking You

Tech Jitendra

JAVA – POLYMORPHISM

Java – Polymorphism

Guided by Bipin Ajay , Founder of Tech Jitendra .


Polymorphism is the ability of an object to take on many forms. The most common use of polymorphism in OOP occurs when a parent class reference is used to refer to a child class object.

Any Java object that can pass more than one IS-A test is considered to be polymorphic. In Java, all Java objects are polymorphic since any object will pass the IS-A test for their own type and for the class Object.

It is important to know that the only possible way to access an object is through a reference variable. A reference variable can be of only one type. Once declared, the type of a reference variable cannot be changed.

The reference variable can be reassigned to other objects provided that it is not declared final. The type of the reference variable would determine the methods that it can invoke on the object.

A reference variable can refer to any object of its declared type or any subtype of its declared type. A reference variable can be declared as a class or interface type.

Example

Let us look at an example.public interface Vegetarian{} public class Animal{} public class Deer extends Animal implements Vegetarian{}

Now, the Deer class is considered to be polymorphic since this has multiple inheritance. Following are true for the above examples −

  • A Deer IS-A Animal
  • A Deer IS-A Vegetarian
  • A Deer IS-A Deer
  • A Deer IS-A Object

When we apply the reference variable facts to a Deer object reference, the following declarations are legal −

Example

Deer d = new Deer(); Animal a = d; Vegetarian v = d; Object o = d;

All the reference variables d, a, v, o refer to the same Deer object in the heap.

Virtual Methods

In this section, I will show you how the behavior of overridden methods in Java allows you to take advantage of polymorphism when designing your classes.

We already have discussed method overriding, where a child class can override a method in its parent. An overridden method is essentially hidden in the parent class, and is not invoked unless the child class uses the super keyword within the overriding method.

Example

/* File name : Employee.java */ public class Employee { private String name; private String address; private int number; public Employee(String name, String address, int number) { System.out.println(“Constructing an Employee”); this.name = name; this.address = address; this.number = number; } public void mailCheck() { System.out.println(“Mailing a check to ” + this.name + ” ” + this.address); } public String toString() { return name + ” ” + address + ” ” + number; } public String getName() { return name; } public String getAddress() { return address; } public void setAddress(String newAddress) { address = newAddress; } public int getNumber() { return number; } }

Now suppose we extend Employee class as follows −/* File name : Salary.java */ public class Salary extends Employee { private double salary; // Annual salary public Salary(String name, String address, int number, double salary) { super(name, address, number); setSalary(salary); } public void mailCheck() { System.out.println(“Within mailCheck of Salary class “); System.out.println(“Mailing check to ” + getName() + ” with salary ” + salary); } public double getSalary() { return salary; } public void setSalary(double newSalary) { if(newSalary >= 0.0) { salary = newSalary; } } public double computePay() { System.out.println(“Computing salary pay for ” + getName()); return salary/52; } }

Now, you study the following program carefully and try to determine its output −/* File name : VirtualDemo.java */ public class VirtualDemo { public static void main(String [] args) { Salary s = new Salary(“Mohd Mohtashim”, “Ambehta, UP”, 3, 3600.00); Employee e = new Salary(“John Adams”, “Boston, MA”, 2, 2400.00); System.out.println(“Call mailCheck using Salary reference –“); s.mailCheck(); System.out.println(“\n Call mailCheck using Employee reference–“); e.mailCheck(); } }

This will produce the following result −

Output

Constructing an Employee Constructing an Employee Call mailCheck using Salary reference — Within mailCheck of Salary class Mailing check to Mohd Mohtashim with salary 3600.0 Call mailCheck using Employee reference– Within mailCheck of Salary class Mailing check to John Adams with salary 2400.0

Here, we instantiate two Salary objects. One using a Salary reference s, and the other using an Employee reference e.

While invoking s.mailCheck(), the compiler sees mailCheck() in the Salary class at compile time, and the JVM invokes mailCheck() in the Salary class at run time.

mailCheck() on e is quite different because e is an Employee reference. When the compiler sees e.mailCheck(), the compiler sees the mailCheck() method in the Employee class.

Here, at compile time, the compiler used mailCheck() in Employee to validate this statement. At run time, however, the JVM invokes mailCheck() in the Salary class.

This behavior is referred to as virtual method invocation, and these methods are referred to as virtual methods. An overridden method is invoked at run time, no matter what data type the reference is that was used in the source code at compile time.

Pls … Follow our website.

Thanking you

Tech Jitendra

METHOD OVER LOADING IN JAVA.

Method Overloading in Java with examples

Method Overloading is a feature that allows a class to have more than one method having the same name, if their argument lists are different. It is similar to constructor overloading in Java, that allows a class to have more than one constructor having different argument lists.

let’s get back to the point, when I say argument list it means the parameters that a method has: For example the argument list of a method add(int a, int b) having two parameters is different from the argument list of the method add(int a, int b, int c) having three parameters.

Three ways to overload a method

In order to overload a method, the argument lists of the methods must differ in either of these:
1. Number of parameters.
For example: This is a valid case of overloadingadd(int, int) add(int, int, int)

2. Data type of parameters.
For example:add(int, int) add(int, float)

3. Sequence of Data type of parameters.
For example:add(int, float) add(float, int)

Invalid case of method overloading:
When I say argument list, I am not talking about return type of the method, for example if two methods have same name, same parameters and have different return type, then this is not a valid method overloading example. This will throw compilation error.int add(int, int) float add(int, int)

Method overloading is an example of Static Polymorphism. We will discuss polymorphism and types of it in a separate tutorial.

Points to Note:
1. Static Polymorphism is also known as compile time binding or early binding.
2. Static binding happens at compile time. Method overloading is an example of static binding where binding of method call to its definition happens at Compile time.

Method Overloading examples

As discussed in the beginning of this guide, method overloading is done by declaring same method with different parameters. The parameters must be different in either of these: number, sequence or types of parameters (or arguments). Lets see examples of each of these cases.

Argument list is also known as parameter list

Example 1: Overloading – Different Number of parameters in argument list

This example shows how method overloading is done by having different number of parametersclass DisplayOverloading { public void disp(char c) { System.out.println(c); } public void disp(char c, int num) { System.out.println(c + ” “+num); } } class Sample { public static void main(String args[]) { DisplayOverloading obj = new DisplayOverloading(); obj.disp(‘a’); obj.disp(‘a’,10); } }

Output:a a 10

In the above example – method disp() is overloaded based on the number of parameters – We have two methods with the name disp but the parameters they have are different. Both are having different number of parameters.

Example 2: Overloading – Difference in data type of parameters

In this example, method disp() is overloaded based on the data type of parameters – We have two methods with the name disp(), one with parameter of char type and another method with the parameter of int type.class DisplayOverloading2 { public void disp(char c) { System.out.println(c); } public void disp(int c) { System.out.println(c ); } } class Sample2 { public static void main(String args[]) { DisplayOverloading2 obj = new DisplayOverloading2(); obj.disp(‘a’); obj.disp(5); } }

Output:a 5

Thanking You

Tech Jitendra

Method Overloading in Java with examples.

Method Overloading is a feature that allows a class to have more than one method having the same name, if their argument lists are different. It is similar to constructor overloading in Java, that allows a class to have more than one constructor having different argument lists.

let’s get back to the point, when I say argument list it means the parameters that a method has: For example the argument list of a method add(int a, int b) having two parameters is different from the argument list of the method add(int a, int b, int c) having three parameters.

Three ways to overload a method

In order to overload a method, the argument lists of the methods must differ in either of these:
1. Number of parameters.
For example: This is a valid case of overloadingadd(int, int) add(int, int, int)

2. Data type of parameters.
For example:add(int, int) add(int, float)

3. Sequence of Data type of parameters.
For example:add(int, float) add(float, int)

Invalid case of method overloading:
When I say argument list, I am not talking about return type of the method, for example if two methods have same name, same parameters and have different return type, then this is not a valid method overloading example. This will throw compilation error.int add(int, int) float add(int, int)

Method overloading is an example of Static Polymorphism. We will discuss polymorphism and types of it in a separate tutorial.

Points to Note:
1. Static Polymorphism is also known as compile time binding or early binding.
2. Static binding happens at compile time. Method overloading is an example of static binding where binding of method call to its definition happens at Compile time.

Method Overloading examples

As discussed in the beginning of this guide, method overloading is done by declaring same method with different parameters. The parameters must be different in either of these: number, sequence or types of parameters (or arguments). Lets see examples of each of these cases.

Argument list is also known as parameter list

Example 1: Overloading – Different Number of parameters in argument list

This example shows how method overloading is done by having different number of parametersclass DisplayOverloading { public void disp(char c) { System.out.println(c); } public void disp(char c, int num) { System.out.println(c + ” “+num); } } class Sample { public static void main(String args[]) { DisplayOverloading obj = new DisplayOverloading(); obj.disp(‘a’); obj.disp(‘a’,10); } }

Output:a a 10

In the above example – method disp() is overloaded based on the number of parameters – We have two methods with the name disp but the parameters they have are different. Both are having different number of parameters.

Example 2: Overloading – Difference in data type of parameters

In this example, method disp() is overloaded based on the data type of parameters – We have two methods with the name disp(), one with parameter of char type and another method with the parameter of int type.class DisplayOverloading2 { public void disp(char c) { System.out.println(c); } public void disp(int c) { System.out.println(c ); } } class Sample2 { public static void main(String args[]) { DisplayOverloading2 obj = new DisplayOverloading2(); obj.disp(‘a’); obj.disp(5); } }

Output:a 5

Example3: Overloading – Sequence of data type of arguments

Here method disp() is overloaded based on sequence of data type of parameters – Both the methods have different sequence of data type in argument list. First method is having argument list as (char, int) and second is having (int, char). Since the sequence is different, the method can be overloaded without any issues.class DisplayOverloading3 { public void disp(char c, int num) { System.out.println(“I’m the first definition of method disp”); } public void disp(int num, char c) { System.out.println(“I’m the second definition of method disp” ); } } class Sample3 { public static void main(String args[]) { DisplayOverloading3 obj = new DisplayOverloading3(); obj.disp(‘x’, 51 ); obj.disp(52, ‘y’); } }

Output:I’m the first definition of method disp I’m the second definition of method disp

Pls … Visit our website

Like , share , subscribe our website .

http//techjitendra.wordpress.com

Thanking You

Tech Jitendra .

C++ program to add two complex numbers

C++ program to add two complex numbers.

C++ programming code

  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. class complex
  6. {
  7.    public :
  8.       int real, img;
  9. };
  10.  
  11. int main()
  12. {
  13.    complex a, b, c;
  14.  
  15.    cout << “Enter a and b where a + ib is the first complex number.”;
  16.    cout << “\na = “;
  17.    cin >> a.real;
  18.    cout << “b = “;
  19.    cin >> a.img;
  20.    cout << “Enter c and d where c + id is the second complex number.”;
  21.    cout << “\nc = “;
  22.    cin >> b.real;
  23.    cout << “d = “;
  24.    cin >> b.img;
  25.    
  26.    c.real = a.real + b.real;
  27.    c.img = a.img + b.img;
  28.  
  29.    if (c.img >= 0)
  30.       cout << “Sum of two complex numbers = ” << c.real << ” + ” << c.img << “i”;
  31.    else
  32.       cout << “Sum of two complex numbers = ” << c.real << ” ” << c.img << “i”;
  33.  
  34.    return 0;
  35. }

Pls … Subscribe our site and like .

Thanking you

Tech Jitendra

A c++ program to display student information using class .

C++ program to display student information using class

Sample Input
Enter Name:Bikash
Enter Reg. no.:123
Enter Branch:CS
Enter Sem:5
Sample Output
Name:Bikash
Regdno.:123
Branch:CS
Sem:5

Subscribe our site

Thanking you

WRITE A GUI PROGRAM TO ADD NUMBER USING AWT.

Java GUI Program to Add Two Numbers Using AWT

Remember that program we did to add two numbers? We are going to simply uptrade! We will create a Java GUI program to add two numbers using AWT and it’s gonna be fun.

Adding two numbers doesn’t have too much of a logic. But when you are doing so while using AWT things become a little challenging. Snice a text field in Java takes in String as input we need to first parse it into the form of Integer.

We are going to create two text fields and a label where the output will be seen. A button will be used to trigger the event.

So let’s get to it.

Java GUI Program to Add Two Numbers Using AWT

Here is the addition program:import java.awt.*; import java.net.*; import java.awt.event.*; public class LearnAWT extends Frame {             TextField tf1;             TextField tf2;             Label l1;             Button b;                     LearnAWT() {                           setTitle(“Adder”);                           tf1 = new TextField();                           tf1.setBounds(100, 50, 85, 20);                           tf2 = new TextField();                           tf2.setBounds(100, 100, 85, 20);                           b = new Button(“Add”);                           b.setBounds(110,220,60,40);                           l1 = new Label(“”);                           l1.setBounds(100, 120, 85, 20);                           add(b);                           add(tf1);                           add(tf2);                           add(l1);                           setSize(300,300);                           setVisible(true);         b.addActionListener(new ActionListener(){                public void actionPerformed(ActionEvent e) {                     int a = Integer.parseInt(tf1.getText());                     int b = Integer.parseInt(tf2.getText());                     int c = a + b;                     l1.setText(“Their sum is = ” + String.valueOf(c));                                       }                 });             } public static void main(String []args) {                    new LearnAWT();           } }

As you can see our main code went into the addActionListener method. We created three variables and parsed the String values into integers. Then for setText we had convert them back to String, and so String’s valueOf() came to the rescue.

Notice, since you are using AWT classes and event handler you need to import the respective classes first or your code wouldn’t work.

Now let’s run the above program.

You will get the following result when you run it:

Java GUI program to add two numbers using AWT

Isn’t that a charm?

Share this:

SUBSCRIBE TO BLOG VIA EMAIL

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Email Address

Subscribe

Thanking you

Tech Jitendra

A C++ PROGRAMME

Tech Jitendra Provides,

C++ program to create student class, read and print N student’s details (Example of array of objects)

This program will explain how to read and print multiple student details using Array of Objects.

Array of objects program in C++

/*C++ program to create student class, read and print N student’s details (Example of array of objects).*/ #include <iostream> using namespace std; #define MAX 10 class student {     private: char name[30]; int rollNo; int total; float perc;     public: //member function to get student’s details void getDetails(void); //member function to print student’s details void putDetails(void); }; //member function definition, outside of the class void student::getDetails(void){ cout << “Enter name: ” ; cin >> name; cout << “Enter roll number: “; cin >> rollNo; cout << “Enter total marks outof 500: “; cin >> total; perc=(float)total/500*100; } //member function definition, outside of the class void student::putDetails(void){ cout << “Student details:\n”; cout << “Name:”<< name << “,Roll Number:” << rollNo << “,Total:” << total << “,Percentage:” << perc; } int main() { student std[MAX]; //array of objects creation int n,loop; cout << “Enter total number of students: “; cin >> n; for(loop=0;loop< n; loop++){ cout << “Enter details of student ” << loop+1 << “:\n”; std[loop].getDetails(); } cout << endl; for(loop=0;loop< n; loop++){ cout << “Details of student ” << (loop+1) << “:\n”; std[loop].putDetails(); } return 0; }

Output Enter total number of students: 2 Enter details of student 1: Enter name: Mike Enter roll number: 101 Enter total marks outof 500: 456 Enter details of student 2: Enter name: Mock Enter roll number: 102 Enter total marks outof 500: 398 Details of student 1: Student details: Name:Mike,Roll Number:101,Total:456,Percentage:91.2Details of student 2: Student details: Name:Mock,Roll Number:102,Total

Thanking You

Tech Jitendra

WRITE A PROGRAM TO MAKE THE CLASS OF A STUDENT TO ENTER NAME,CLASS,ROLL NO AND FATHER NAME.

Tech Jitendra Provides ,

Discussion about this program.

SIMPLE CLASSES

Explanation of Question:   Write a program to make the class of a student to enter name,class,roll no and father name using int get() to take input and int out function to display input.

use dev c++ to run this program.

#include<iostream>

using namespace std;

class student     //declaring class , the class name is student

{

private:     // using private access specifiers

int Roll;

char Name[40];                   //it can take the input of 40 characters

char cls[10];                    //it can take the input of 10 characters

char Fathername[40];             //it can take the input of 40 characters

public:    //access specifiers

int get()   //using function to take input

{

//stating fuction body

cout<<“Enter the name: “<<endl;

gets(Name);   //using gets to use space in name

cout<<“Enter the Father name: “<<endl;

gets(Fathername);

cout<<“Enter the Roll No: “<<endl;

cin>>Roll;

cout<<“Enter the class: “<<endl;

cin>>cls;

}

int out()    //using function to get/display output

{

//starting function body

cout<<“The Name is “<<Name<<endl;

cout<<“The Roll No is “<<Roll<<endl;

cout<<“The Father Name is “<<Fathername<<endl;

cout<<“The class is “<<cls<<endl;

}

};  //end of class

int main()

{

student s1;

s1.get();

s1.out();

system(“pause”);

}

Design a site like this with WordPress.com
Get started