Wednesday, November 2, 2022

INTRODUCTION TO COMPUTER NETWORKS

A Computer network consists of two or more autonomous computers that are linked (connected) together in order to:

Share resources (files, printers, modems, fax machines).

Share Application software like MS Office.

Allow Electronic communication.

Increase productivity (makes it easier to share data amongst users).

The Computers on a network may be linked through Cables, telephones lines, radio waves, satellites etc.

A Computer network includes, the network operating system in the client and server machines, the cables, which connect different computers and all supporting hardware in between such as bridges, routers and switches. In wireless systems, antennas and towers are also part of the network.


Computer networks are generally classified according to their structure and the area they are localised in as:

Local Area Network (LAN): The network that spans a relatively small area that is, in the single building or campus is known as LAN.

Metropolitan Area Network (MAN): The type of computer network that is, designed for a city or town is known as MAN.

Wide Area Network (WAN): A network that covers a large geographical area and covers different cities, states and sometimes even countries, is known as WAN.


CLASSIFICATION OF NETWORKS

Depending on the transmission technology i.e., whether the network contains switching elements or not, we have two types of networks:

·             Broadcast networks.

·             Point-to-point or Switched networks.

Broadcast networks have a single communication channel that is shared by all the machines on the network. In this type of network, short messages sent by any machine are received by all the machines on the network. 

The different types of Broadcast networks are:

1)               Packet Radio Networks.

2)               Satellite Networks.

3)               Local Area Networks.

Point-to-Point or Switched Networks

Point–to-point or switched, networks are those in which there are many connections between individual pairs of machines. In these networks, when a packet travels from source to destination it may have to first visit one or more intermediate machines.

Routing algorithms play an important role in Point-to-point or Switched networks because often multiple routes of different lengths are available.

An example of a switched network is the international dial-up telephone system. The different types of Point-to-point or Switched networks are:

  • Circuit Switched Networks.
  • Packet Switched Networks.

NETWORK TOPOLOGY

Some of the most common network topologies are:

  • Bus topology
  • Star topology
  • Ring topology
  • Tree topology 
  • Mesh topology
  • Cellular topology

 

Saturday, January 22, 2022

General Exception Handling Questions

General Exception Handling Questions

  1. What are the two types of Exceptions in Java? Which are the differences between them?
  2. What is the difference between Exception and Error in java?
  3. What is the difference between throw and throws?
  4. What is the importance of finally block in exception handling?
  5. What will happen to the Exception object after exception handling?
  6. How does finally block differ from finalize() method?

The above is Exception handing Questions, Now let us discuss all the questions one by one, which helps to increase your knowledge in Java.

What are the two types of Exceptions in Java? Which are the differences between them?

Java has two types of exceptions: checked exceptions and unchecked exceptions. Unchecked exceptions do not need to be declared in a method or a constructor’s throws clause if they can be thrown by the execution of the method or the constructor, and propagate outside the method or constructor boundary. On the other hand, checked exceptions must be declared in a method or a constructor’s throws clause. See here for tips on Java exception handling.

What is the difference between Exception and Error in java?

Exception and Error classes are both subclasses of the Throwable class. The Exception class is used for exceptional conditions that a user’s program should catch. The Error class defines exceptions that are not excepted to be caught by the user program.

What is the difference between throw and throws?

The throw keyword is used to explicitly raise a exception within the program. On the contrary, the throws clause is used to indicate those exceptions that are not handled by a method. Each method must explicitly specify which exceptions does not handle, so the callers of that method can guard against possible exceptions. Finally, multiple exceptions are separated by a comma

What is the importance of finally block in exception handling?

A finally block will always be executed, whether or not an exception is actually thrown. Even in the case where the catch statement is missing and an exception is thrown, the finally block will still be executed. The last thing to mention is that the finally block is used to release resources like I/O buffers, database connections, etc.

What will happen to the Exception object after exception handling?

The Exception object will be garbage collected in the next garbage collection.

How does finally block differ from finalize() method?

A finally block will be executed whether or not an exception is thrown and is used to release those resources held by the application. Finalize is a protected method of the Object class, which is called by the Java Virtual Machine (JVM) just before an object is garbage collected

Thursday, January 20, 2022

General Questions about Java

 General Questions about Java

  1. What is JVM? Why is Java called the Platform Independent Programming Language?
  2. What is the Difference between JDK and JRE?
  3. What does the “static” keyword mean? Can you override the private or static methods in Java?
  4. Can you access non-static variables in a static context?
  5. What are the Data Types supported by Java? What are Autoboxing and Unboxing?
  6. What is Function Overriding and Overloading in Java?
  7. What is a Constructor, Constructor Overloading in Java, and Copy-Constructor?
  8. Does Java support multiple inheritances?
  9. What is the difference between an Interface and an Abstract class?
  10. What is pass by reference and pass by values?
The above is General Questions about Java, Now let us discuss all the questions one by one, which helps to increase your knowledge in Java.

What is JVM? Why is Java called the Platform Independent Programming Language?

A Java virtual machine (JVM) is a process virtual machine that can execute Java bytecode. Each Java source file is compiled into a bytecode file, which is executed by the JVM. Java was designed to allow application programs to be built that could be run on any platform, without having to be rewritten or recompiled by the programmer for each separate platform. A Java virtual machine makes this possible because it is aware of the specific instruction lengths and other particularities of the underlying hardware platform.

What is the Difference between JDK and JRE?

The Java Runtime Environment (JRE) is basically the Java Virtual Machine (JVM) where your Java programs are being executed. It also includes browser plugins for applet execution. The Java Development Kit (JDK) is the full-featured Software Development Kit for Java, including the JRE, the compilers and tools (like JavaDoc, and Java Debugger), in order for a user to develop, compile and execute Java applications.

What does the “static” keyword mean? Can you override the private or static methods in Java?

The static keyword denotes that a member variable or method can be accessed, without requiring an instantiation of the class to which it belongs. A user cannot override static methods in Java, because method overriding is based upon dynamic binding at runtime and static methods are statically binded at compile time. A static method is not associated with any instance of a class so the concept is not applicable.

Can you access non-static variables in a static context?

A static variable in Java belongs to its class and its value remains the same for all its instances. A static variable is initialized when the class is loaded by the JVM. If your code tries to access a non-static variable, without any instance, the compiler will complain, because those variables are not created yet and they are not associated with any instance.

What are the Data Types supported by Java? What are Autoboxing and Unboxing?

The eight primitive data types supported by the Java programming language are:

• byte

• short

• int

• long

• float

• double

• boolean

• char

Autoboxing is the automatic conversion made by the Java compiler between the primitive types and their corresponding object wrapper classes. For example, the compiler converts an int to an Integer, a double to a Double, and so on. If the conversion goes the other way, this operation is called unboxing.

What is Function Overriding and Overloading in Java?

Method overloading in Java occurs when two or more methods in the same class have the exact same name, but different parameters. On the other hand, method overriding is defined as the case when a child class redefines the same method as a parent class. Overridden methods must have the same name, argument list, and return type. The overriding method may not limit the access of the method it overrides.

What is a Constructor, Constructor Overloading in Java, and Copy-Constructor?

A constructor gets invoked when a new object is created. Every class has a constructor. In case the programmer does not provide a constructor for a class, the Java compiler (Javac) creates a default constructor for that class. The constructor overloading is similar to method overloading in Java. Different constructors can be created for a single class. Each constructor must have its own unique parameter list. Finally, Java does support copy constructors like C++, but the difference lies in the fact that Java doesn’t create a default copy constructor if you don’t write your own.

Does Java support multiple inheritances?

No, Java does not support multiple inheritance. Each class is able to extend only on one class but is able to implement more than one interface.

What is the difference between an Interface and an Abstract class?

Java provides and supports the creation both of abstract classes and interfaces. Both implementations share some common characteristics, but they differ in the following features:

• All methods in an interface are implicitly abstract. On the other hand, an abstract class may contain both abstract and nonabstract methods.

• A class may implement a number of Interfaces, but can extend only one abstract class.

• In order for a class to implement an interface, it must implement all its declared methods. However, a class may not implement

all declared methods of an abstract class. Though, in this case, the subclass must also be declared as abstract.

• Abstract classes can implement interfaces without even providing the implementation of interface methods.

• Variables declared in a Java interface is by default final. An abstract class may contain non-final variables.

• Members of a Java interface are public by default. A member of an abstract class can either be private, protected, or public.

• An interface is absolutely abstract and cannot be instantiated. An abstract class also cannot be instantiated but can be invoked if it contains the main method.

What is pass by reference and pass by values?

When an object is passed by value, this means that a copy of the object is passed. Thus, even if changes are made to that object, it doesn’t affect the original value. When an object is passed by reference, this means that the actual object is not passed, rather a reference of the object is passed. Thus, any changes made by the external method, are also reflected in all places.


INTRODUCTION TO COMPUTER NETWORKS

A Computer network consists of two or more autonomous computers that are linked (connected) together in order to: • Share resources (files...