JAVA STATIC KEYWORD

JAVA STATIC KEYWORD

In Java, the static keyword is used for memory management. We can apply static keyword with variables, methods, blocks and nested classes. The static keyword belongs to the class than an instance of the class.

Java static variable:

If you declare any variable as static, it is known as a static variable.
The static variable can be used to refer to the common property of all objects (which is not unique for each object), for example, the company name of employees, college name of students, etc.
The static variable gets memory only once in the class area at the time of class loading.

Advantages of static variable

It makes your program memory efficient (i.e., it saves memory).

Understanding the problem without static variable

class Mca{ 
     int roll_no; 
     String name; 
     String college="ITS"; 

Suppose there are 500 students in my class, now all instance data members will get memory each time when the object is created. All students have its unique roll_no and name, so instance data member is good in such case. Here, "college" refers to the common property of all objects. If we make it static, this field will get the memory only once.

Static Methods:

If you apply static keyword with any method, it is known as static method.
A static method belongs to the class rather than the object of a class.
A static method can be invoked without the need for creating an instance of a class.
A static method can access static data member and can change the value of it.

Example of static method


//Java Program to demonstrate the use of a static method. 

class Student{ 
     int rollno; 
     String name; 
     static String college = "ITS"; 
     //static method to change the value of static variable 
     static void change(){ 
     college = "BBDIT"; 
     } 
     //constructor to initialize the variable 
     Student(int r, String n){ 
     rollno = r; 
     name = n; 
     } 
     //method to display values 
     void display(){System.out.println(rollno+" "+name+" "+college);} 
//Test class to create and display the values of object 
public class TestStaticMethod { 
    public static void main(String args[]){ 
    Student.change();//calling change method 
    //creating objects 
    Student s1 = new Student(111,"Karan"); 
    Student s2 = new Student(222,"Aryan"); 
    Student s3 = new Student(333,"Sonoo"); 
    //calling display method 
    s1.display(); 
    s2.display(); 
    s3.display(); 
    } 

Output:111 Karan BBDIT
       222 Aryan BBDIT
       333 Sonoo BBDIT


Another example of a static method that performs a normal calculation

//Java Program to get the cube of a given number using the static method 
 
class Calculate{ 
  static int cube(int x){ 
  return x*x*x; 
  } 
 
  public static void main(String args[]){ 
  int result=Calculate.cube(5); 
  System.out.println(result); 
  } 

Restrictions for the static method

There are two main restrictions for the static method. They are:

The static method can’t use non static data member or call non-static method directly.
this and super cannot be used in static context.
class A{ 
 int a=40;//non static 
    public static void main(String args[]){ 
  System.out.println(a); 
 } 
}    

Important Points:

When to use static methods?

When you have code that can be shared across all instances of the same class, put that portion of code into static method.
They are basically used to access static field(s) of the class.

Instance method vs Static method

Instance method can access the instance methods and instance variables directly.
Instance method can access static variables and static methods directly.
Static methods can access the static variables and static methods directly.
Static methods can’t access instance methods and instance variables directly. They must use reference to object. And static method can’t use this keyword as there is no instance for ‘this’ to refer to.

Why is the Java main method static?

It is because the object is not required to call a static method. If it were a non-static method, JVM creates an object first then call main() method that will lead the problem of extra memory allocation.

What is class and objects in java? | What is the difference between class and object?


What is class in java?

Class is a blueprint. In Java everything is encapsulated under classes.  A class is used to bind data as well as methods together as a single unit. Class will have:
  • ·    Attributes (instance Variables)
  • ·    Methods (Functions)

the instance variables and methods are known as class members.

What is Object?

An object is the instance of the class, which helps programmers to use (access) variables and methods inside the class. Given a class you can create how much ever objects you want.
The objects (also called instances) are created using new keyword.

Syntax for creating an object of the class:

ClassName objectName = new className();
Here, we are using the constructor (className()) to create the object. Don’t get bothered about constructor. We will learn the constructor in next class.

How to access members?

Objects are used to access members of the class. We can access members of the class (methods and access instance variables) by using the . operator. We will see in the example.

Object and Class Example: main( ) within the class

In this example, we have created a Student class which has two data members: id and name. We are creating the object of the Student class by new keyword and printing the object's value.

//Java Program to illustrate how to define a class and fields 

//Defining a Student class. 
class Student{ 
 //defining members of the class
 int id; //field or data member or instance variable 
 String name; 
 //creating main method inside the Student class  
 public static void main(String args[]){ 
  //Creating an object or instance 
  Student s1=new Student();//creating an object of Student 
  //Printing values of the object 
  System.out.println(s1.id);//accessing member through object 
  System.out.println(s1.name); 
 } 
} 

Output:

0            // because we have not yet assigned any value.
null

Object and Class Example: main outside the class

In real time development, we create classes and use it from another class. It is a better approach than previous one. Let's see a simple example, where we are having main() method in another class.
We can have multiple classes in different Java files or single Java file. If you define multiple classes in a single Java source file, it is a good idea to save the file name with the class name which has main() method.

//Java Program to demonstrate having the main method in  another class 

//Creating Student class. 
class Student{ 
 int id; 
 String name; 
} 
//Creating another class TestStudent1 which contains the main method 
class TestStudent1{ 
 public static void main(String args[]){ 
  Student s1=new Student(); 
  s1.id=5;
s1.name=’’hi”;
System.out.println(s1.id); 
 System.out.println(s1.name); 
 } 
} 

Output:

5
hi


Carrer Opportunities after MCA | Government jobs after MCA

I am also a MCA graduate from Chandigarh University. Here i am showing you all the further directions that can be done after MCA. The further directions might be jobs (govt or private), higher studies, entrepreneurship, etc.

Government jobs after MCA

  • NIC
  • Banking
  • Assistant Professor
  • Lecturer in Higher Secondary School
  • Junior Assistant Jobs in various departments
  • Many other State SSB jobs.

NIC: You can apply for the position of Scientist or Technical Assistant in the NIC (National Information Centre).

Further studies after MCA

  • PhD
  • M.Phil
  • MBA
  • Mtech
  • Any other master degree
I suggest you to pursue PhD if you are interested in further studies. So in accordance, it is required to clear UGC NET, if some one wants to pursue PhD in reputed institutions for getting fellowship. However, UGC NET is not mandatory.

Private Jobs after MCA

It is suggested to go in MNC as software engineer role.




File Handling in Java


File Handling in java

This topic is also known as IOStream or Java IO. Java I/O (Input and Output) is used to process the input and produce the output.
Java uses the concept of a stream to make I/O operation fast. The java.io package contains all the classes required for input and output operations.


Some input-output stream will be initialized automatically by the JVM and these streams are available in System class as in, out, and err variable.

In refers to the default input device, i.e. keyboard. (System.in…)
Out and err refers to the default output device, i.e. console. (System.out…..)

Streams:

Streams are the sequence of bits (data).

Types of Streams on the basis of flow of data:

  • Input Streams
  • Output Streams

Input Streams: Input streams are used to read the data from various input devices like keyboard, file, network, etc.
Output Streams: Output streams are used to write the data to various output devices like monitor, file, network, etc.

Types of streams based on type of data:

Byte Stream: used to read or write byte data.
Character Stream: used to read or write character data.


Byte Input Stream

These are used to read byte data from various input devices.
InputStream is an abstract class and it is the super class of all the input byte streams.

List of Byte Input Streams:

ObjectInputStream, ByteArrayInputStream, InputStream, DataInputStream, BufferedInput Stream, FileInputStream.

Useful methods of InputStream

1) public abstract int read()throws IOException: It reads the next byte of data from the input stream. It returns -1 at the end of the file.
2) public int available()throws IOException: It returns an estimate of the number of bytes that can be read from the current input stream.
3) public void close()throws IOException: It is used to close the current input stream.

Byte Output Stream:

These are used to write byte data to various output devices.
OutputStream is an abstract class and it is the superclass for all the output byte streams.

List of Byte Output Streams:

ObjectOutputStream, ByteArrayOutputStream, OutputStream, DataOutputStream, BufferedOutputStream, FileOutputStream

Useful methods of OutputStream:

1) public void write(int)throws IOException: It is used to write a byte to the current output stream.
2) public void write(byte[])throws IOException: It is used to write an array of byte to the current output stream.
3) public void flush()throws IOException: It flushes the current output stream.
4) public void close()throws IOException: It is used to close the current output stream.

Character Input Stream:

These are used to read char data from various input devices.
Reader is an abstract class and is the super class for all the character input streams.
List of Character Input Streams:

Character Output Stream: 

These are used to write char data to various output devices.
Writer is an abstract class and is the super class of all the character output streams.

Example to read contents of file using File Input Stream:


import java.io.*;
class Sudan{
public static void main(String args[]){
try{
FileInputStream fin=new FileInputStream(“hello.txt”);
int i=0;
while((i=fin.read())!=-1){
System.out.println((char)i);
}
fin.close();
} catch(Exception e){
system.out.println(e);}
}
}
}

 Example to write in a file using FileOutputStream:


import java.io.*;
public class Sudan{
public static void main(String args[]){
try{
FileOutputstream fo=new FileOutputStream(“hello.txt”);
String i=”Hello “;
byte b[]=i.getBytes();/ /converting string into byte array
fo.write(b);
fo.close();
}
catch(Exception e){
system.out.println(e);}
}
}


The best countries and preferable universities for pursuing PhD are:

  • US

  • Germany

  • Australia

  • France

  • Switzerland

  • Zealand

  • Japan

  • Canada

  • India

What is a Search Engine? | How does a search engine work? | Popular examples of search engines

A search engine is an application which is used to find the information from the web servers. We just provide some keywords to search engine, and in return the search engine provides us the information we need.

In this post, we will cover the following contents:

  • What is a search engine?
  • Popular examples of search engines.
  • What are the different types of Search Engines?
  • How does search engine works?
  • How to use the search engine effectively?

WHAT IS A SEARCH ENGINE?

A search engine is a software system which is designed to search the World Wide Web in a specified way for getting the information specified in search query. Popular examples of search engines are Google, Bing, Yahoo, DuckDuckGo etc; 

WHAT ARE POPULAR EXAMPLES OF SEARCH ENGINES?

The most popular examples of search engines are provided below:
  • Google 
  • Bing 
  • Yahoo 
  • Baidu 
  • Yandex 
  • DuckDuckGo 
  • Ask.com 
  • AOL.com 
  • WolframAlpha 
  • Internet Archive

Search Market Share Worldwide

Search EngineShare Market
Google91.5%
Bing2.55%
Yahoo1.64%
Baidu1.44%
Yandex0.45%
DuckDuckGo0.28%
Ask.com0.23%
Aol.comNA
WolframeAlphaNA
Internet ArchiveNA


Google

It is the most popular search engine used worldwide. The most relevant results provided by the Google make it the most popular and trusted search engine. Other products are provided by Google company are Youtube, Google Drive, Google Maps, Gmail, etc.

Bing

The popular search engine after the Google is Bing. It is owned by the Microsoft which was originated to challenge Google in search results but despite their best efforts, they are not able to convince the users that Bing can be alternate to the Google. It is the default search engine on the Internet Explorer.

Yahoo

It is one of the popular search engines. It comes at the third place in search which share 2% of the market share.

Baidu 

It is the most popular search engine in Chine which was founded in 2000. Although it can be used from any region, yet it is available in the chinese language.

DuckDuckGo

Unlike Google and Yahoo, this search engine doesn't own its own search index. It relies on other data sources. The main thing of this search engine that makes it different from other search engines is that it doesn't store users data. For the privacy issues, users can make use of this search engine.

Ask.com

It is based on question and answers based format where most of the answers are provided by the users.

WHAT ARE THE DIFFERENT TYPES OF SEARCH ENGINES?


  • Crawler-Based Search Engines
  • Human-Powered Directories
  • Hybrid Search Engines Or Mixed Results
  • Meta Search Engine

Crawler-Based Search Engines

Crawler-based search engines, such as Google, create their listings automatically. They "crawl" or "spider" the web, then people search through what they have found.

Human-Powered Directories

A human-powered directory, such as the Open Directory, depends on humans for its listings. You submit a short description to the directory for your entire site, or editors write one for sites they review. A search looks for matches only in the descriptions submitted. 

Hybrid Search Engines Or Mixed Results

In the web's early days, it used to be that a search engine either presented crawler-based results or human-powered listings. Today, it extremely common for both types of results to be presented.

Meta Search Engine

These types of search engines don't own their own database. They rely on another search engines in a way. In these search engine, the user query provided by a user is further send to another multiple search engines. The retrieved results from the several search engines are further combined and generate a list. This final list is presented to user by Meta Search Engine.

HOW DOES SEARCH ENGINE WORK?

Search Engine mostly have four primary functions:
  • Crawling
  • Indexing
  • Ranking
  • Query Matching

Crawling

It is the process of discovering important pages on the web. Many bots are used by search engines for this purpose.

Indexing

It stores all the crawled pages with useful information known as tags for each web page.

Ranking

It ranks and sort the web pages with respect to the ranking of the web pages for relevant queries.

Let's understand the working of search engine in details.
In order to get the results from the web, a user submits query to search engine. The search engine initially pre-processes the user query. The pre-processing includes tokenization, stopwords removal, stemming, and spelling correction. 
After preprocesing, the preprocessed and tokenized keywords are matched directly (Query Matching) to indexer of the search engine. The most relevant web documents are fetched from the database and presented to the user sorted on the basis of the ranking of the web documents.

What is Web Personalization? Process of Personalization

|WEB PERSONALIZATION | THREE GENERATIONS OF THE WEB |

WEB PERSONALIZATON

Web Personalization is the process of customizing a website to the needs of specific users. It is the process of providing a unique experience to the every user. For example, if a person sitting at India is using Amazon, the person will be showed up the results which are most frequently purchased or viewed by Indians. This is called web Personalization.
Let's understand, when and how the process of Personalization generated with the help of different generations of the web.

THREE GENERATIONS OF THE WEB

  • Web 1.0.
  • Web 2.0.
  • Web 3.0.

Web 1.0

It is the first generation of the web. It was read only web. In this generation of the web, the users are allowed only to read the information. It was very limited due to the limited resources. It was same like as we read newspaper. In this generation, the users were not able to provide the feedback or comment on an information. Moreover, they couldn't communicate effectively with the others users.

Web 2.0

This generation of the web removes the disadvantages of the first generation of the web. It is also called as the read and write generation of the web. In this generation, two way communication is possible. for example, blogging, where users can interact with the author of the contents.
But the main disadvantages of this generation are lack of semantic web and lack of Personalization.

Web 3.0

The current web is 3.0. It incorporates the process of Personalization and semantic web. Semantic web is also known as the extension of the web 2.0. In semantic web, a lot of annotations  and semantic tags are used on the web to make the information machine understandable.
You can also understand the Personalization with respect to the web mining and the three techniques of the web mining,

What is Web Mining? What are different techniques of webmining?

PROCESS OF WEB PERSONALIZATION

Web Personalization is divided into three main phases:
  • Learning
  • Matching
  • Recommendation

Learning

In the first phase, information of the user is collected which is further used to personalize the contents of a website. This information may be like the name of the user, age, sex, his past clicked documents etc.
The information can be collected in two ways: Implicit learning and Explicit Learning. In implicit learning, the information is collected without the intervention of the user. In explicit learning, the users are asked to provide the information.

Matching

In this phase, the collected information of the user is matched with the contents of the web pages. After matching the users' information and contents of a web page, most matching and suitable contents are provided to user.
In this phase, many filtering algorithms are used like Collaborative filtering, Content Based Filtering, Rule Based Filtering, Hybrid Filtering.

Recommendation

The last phase is recommendation which provides the best matched items to the user.

What is Web Mining? What are different techniques of web mining?

|Web Mining | Three techniques of the web mining|

WEB MINING

Web Mining is the process of mining the useful information from the web. It can be better understand with the help of looking the working of a search engine. Search engine actually works on the principles of web mining. There are three techniques used in web mining.

THREE TECHNIQUES OF WEB MINING

  • Web Content Mining.
  • Web Structure Mining.
  • Web Usage Mining.

Web Content Mining

Web Content Mining is the process of analyzing the contents of web pages. It is also knows as the web scrapping or web harvesting.

Web Structure Mining

Web Structure Mining is the process of knowing the relationships among the different web pages like how the web pages are interlinked with one another. It is also used to find the ranking of a web page. Many algorithms are used for finding the ranking of a web page. Alexa Ranking, Page Ranking algorithm, HITS algorithm, etc, are the examples of page ranking algorithms. Page Ranking algorithm which was developed by the Larry page, owner of the Google.

Web Usage Mining

Web Usage Mining is used to personalize the information to the users. In web usage mining, the past history of the users is used in order to personalize the information.

Schedule of Examination for UGC NET June 2020.

The UGC NET is conducted in two shifts: morning shift and evening shift. The details of these two shifts is shown:

FIRST SHIFT
Schedule of Examination Between 15 June 2020 to 20 June 2020
Timing of Examination 09.30 am- 12.30 pm
Duration of Examination 03 hours
Entry into the Examination Centre 7.30 am - 8.30 am
Entry in the Examination 8.45 am- 9.00 am
Instructions by the invigilators 9.15 am -9.25 am
Test Commences 9.30 am
Test Concludes 12.30 pm



SECOND SHIFT
Schedule of Examination Between 15 June 2020 to 20 June 2020
Timing of Examination 02.30 pm- 5.30 pm
Duration of Examination 03 hours
Entry into the Examination Centre 12.30 pm -1.30pm
pm
Entry in the Examination 1.45 pm- 2.00 pm
Instructions by the invigilators 2.15 pm- 2.25 pm
Test Commences 2.30 pm
Test Concludes 05.30 pm

All about journals and research paper | What is impact factor? | how the impact factor is calculated? | who calculate the impact factor? Scopous journals

Figure 1: One of my Research Papers When the Scholars are in their Master or PhD or in any research field. They are supposed to writ...