WARNING: Android Spyware Detected Which Spies on Skype, Whatsapp Calls

In order to protect Android users from malware and suspicious apps, Google has been continuously working to detect and remove malicious apps from your devices using its newly launched Google Play Protect service.
Google Play Protect-- a security feature that uses machine learning and app usage analysis to check devices for possibly harmful apps-- recently helped Google researchers to recognize a new deceptive family of Android spyware that was stealing a whole lot of information on users.
Found on targeted devices in African countries, Tizi is a fully-featured Android backdoor with rooting capabilities that installs spyware apps on victims' devices to steal supersensitive data from popular social media apps like WhatsApp, Twitter, Facebook, Linkedin, Skype, Viber, and Telegram.
" The Google Play Protect security team discovered this family in September 2017 when device scans found an app with rooting capabilities that exploited old vulnerabilities," Google said in a blog post. "The team used this app to locate more applications in the Tizi family, the oldest of which is from October 2015."
Most Tizi-infected apps are being advertised on social media websites and 3rd-party app stores, deceiving users into installing them.
Once installed, the innocent looking app acquires root access of the infected device to install spyware, which then first contacts its command-and-control servers by sending an SMS text message with the GPS coordinates of the infected device to a specific number.

Here is How Tizi Gets Root Access On Infected Devices:

For gaining root access, the backdoor exploits previously disclosed vulnerabilities in older chipsets, devices, and Android versions, including CVE-2012-4220, CVE-2013-2596, CVE-2013-2597, CVE-2013-2595, CVE-2013-2094, CVE-2013-6282, CVE-2015-1805, cve-2014-3153, and cve-2015-3636.
If the backdoor not able to get root access on the infected device due to all the listed vulnerabilities being patched, "it will still attempt to perform some actions through the high level of permissions it asks the user to grant to it, mainly around reading and sending SMS messages and monitoring, redirecting, and preventing outgoing phone calls," Google said.
Tizi spyware also been developed to communicate with its command-and-control servers over normal HTTPS or using MQTT messaging protocol to receive commands from the attackers and uploading stolen data.
The Tizi backdoor contains various abilities common to commercial spyware, such as

  • Stealing data from popular social media platforms including Facebook, Twitter, WhatsApp, Viber, Skype, LinkedIn, and Telegram.
  • Recording calls from WhatsApp, Viber, and Skype.
  • Receiving and sending SMS messages.
  • Gain access to calendar events, call log, contacts, images, and list of installed apps
  • Stealing Wi-Fi encryption keys.
  • Recording ambient audio and taking pictures without displaying the image on the device's screen.

Far Google has identified 1,300 Android devices infected by Tizi and removed it.
Majority of which were located in African countries, specifically Kenya, Nigeria, and Tanzania.

How to Protect your Android device from Hackers?

Such Android spyware can be used to target your devices as well, so you if own an Android device, you are strongly encouraged to follow these simple steps in order to secure yourself:

  • Ensure that you have already opted for Google Play Protect.
  • Download and install apps only from the official Play Store, and always check permissions for each app.
  • Enable 'verify apps' feature from settings.
  • When remains unattended, protect your devices with pin or password lock so that nobody can gain unauthorized access to your device.
  • Keep "unknown sources" disabled while not using it.
  • Keep your device always up-to-date with the latest security patches.

What is Multithreading? JAVA Multithreading Tutorial


It is almost end of 2017. The computer has evolved throughout its age from a simple, huge machine which was used for just simple numerical calculations to a small and swift electronic device which is affecting almost every aspect of our life. There are a lot of efforts involved in these enhancements in both hardware and software. Powerful hardware has been invented, and robust software techniques have been designed to improve hardware efficiency. One of these methods is multithreading and this is what we are going to talk about.
Multithreading is the ability of a single processing unit to execute multiple programs concurrently, apparently supported by the operating system. Multithreading is achieved either by multithreaded architecture or by software techniques or by both. All processors and OSs today support multi-thread execution.
We are talking about multithreading but what actually a thread is? A thread is a single unit a single processor can execute. The group consists of the shortest sequence of programmed instructions that are independently managed by operating system. Do not confuse thread with process and multithreading with multiprocessing. A running program, code to which processor is currently assigned is called a process while a thread may be the subpart of a process. A single process can have more than one threads. Multiple threads can share the same resources such as memory while processes do not share any resource with each other.

Advantages of multithreading:

Responsiveness: 

In a one-thread process, if the main execution thread blocks on a long-running task, the entire application can appear to freeze. By moving such long-running tasks to a worker thread that runs concurrently with the main execution thread, it is possible for the application to remain responsive to user input while executing tasks in the background. So multithreading can allow an application to remain responsive to user input.

Faster execution: 

Multithreading allows parallel execution and parallel execution leads to improved CPU performance.

Lower resource consumption:

 Different threads of the same process share same resources.

Better system utilization:

 In a single thread execution, resources can remain idle for some time. Multithreading technique does not allow any resource to be blocked and make use of it by a thread which requires the resource.

Simplified sharing and communication: 

Threads can communicate through data, code, and files they already shared. Unlike processes, threads do not require a message passing or shared memory mechanism to perform inter-process communications.

Parallelization: 

Applications running on multi-core or multi-CPU systems can use multithreading to divide the data and tasks into independent subtasks and let it run in parallel or concurrently.

The life cycle of a Thread:

A thread goes through different stages of its life cycle. It can be in one of the following states.
NEW – A thread that is just created and not yet started.
RUNNABLE – A thread in execution is in this state.
BLOCKED – a thread that is waiting to gain access to some resources is in BLOCKED state of the life-cycle.
WAITING – A thread is in WAITING state if it is waiting for another thread to complete execution.
TERMINATED – A thread that has completed its execution.

Java multithreading example: 

In Java, multithreading can be achieved in multiple ways. We are going to talk about 3 methods here.
1. By implementing Runnable interface.
2. By extending Thread class
3. By creating Thread object

1. By implementing Runnable interface:

MyThread.java
public class MyThread implements Runnable{

 int threadNum;
 int t;
 
 public MyThread(int threadNo) {
  this.threadNum = threadNo;
  t = 10;
 }
 public void run() {
  for (int  i = 0; i < 10; i++) {
   System.out.println("thread#" + threadNum + " : " + t);
   t = i;
  }
 } 
}
MainClass.java

public class MainClass {
 public static void main(String[] args) {
  ExecutorService application = Executors.newCachedThreadPool();
  application.execute(new MyThread(1));
  application.execute(new MyThread(2));
 }
}

2. By extending Thread class:

MyThread.java
public class MyThread extends Thread{
 int threadNum;
 public MyThread(int num) {
  threadNum = num;
 }
 
 public void run () {
  for (int i = 0; i < 10; i++)
  System.out.println(i + " at thread: " + threadNum);
 }
}
MainClass.java



public class MainClass {

 public static void main(String[] args) {
  MyThread t1 = new MyThread(1);
  MyThread t2 = new MyThread(2);
  
  t1.start();
  t2.start();
 }

}

3. By creating Thread object:


public class MainClass {

 public static void main(String[] args) {
  Thread t1 = new Thread(new Runnable() {

   public void run() {
    for (int i = 0; i < 10; i++)
     System.out.println("thread 1 running");
   }
   
  });
  Thread t2 = new Thread(new Runnable() {

   public void run() {
    for (int i = 0; i < 10; i++)
     System.out.println("thread 2 running");
   }
   
  });
  
  t1.start();
  t2.start();
 }
}
If you have any question, ask in the comments. I will try to respond ASAP.

10 Different Types Of Bosses And How To Work With Them

There are a lot of factors which can affect your work potentials such as technology, stress, ego clashes, health, perceived discrimination, and The Boss. Getting to know the type of your Boss you have is an important step towards having a professional relationship with them. After all, your Boss can dictate whether your stay with the company will be in favor of the organization or not. He/She is the one who decides to keep you or to kick you out.
Here are 10 different types bosses and how you can relate to them.

1. The Workaholic

The workaholic is a boss who tends to work overtime, even during holidays. They are typically extremely enthused about completing undertakings on time and will recommend additional work hours keeping in mind the end goal to accomplish this. The vast majority of them barely go on sick days or take leaves from office.
Working under a workaholic can be stressful, especially if you’re not one. There’s a high chance it will greatly impact on your work-life balance. If you want to get yourself promoted in this sort of environment, make sure you complete your work on time. They will have no reason to hold you back for more work.

2. The Visionary

Visionary bosses tend to dream a lot about the company’s potential, and the future. They have a lot of ideas about which direction the company can take but usually lack the initiation capability.
In order for you to charm yourself to a visionary boss, always attempt to enable them to accomplish their ambitions. Make a contribution to help them understand their goals and follow it up on a regular basis. If everything works fine, they will have you to thank and you might get a promotion for it.

3. The Micro Manager

Micromanagers are dreaded in any workplace. Most bosses tend to become micro managers whenever the company is making losses. They will start concentrating on every single action you make, be it work or non-work related. They might concentrate on things like how long you took during lunch, what amount of work you’ve been able to deliver in a day or how much time you’ve spent on the phone.
If you have this type of boss, the solution that will work for you is to keep them busy. The only way to achieve this is by making sure you complete your tasks in time. They will have so much work to review that they will forget about micromanaging.

4. The Pace-setter

Pace-setter bosses like to test their employees by giving them constant tasks in order to find how good they are. They might give you challenging tasks to accomplish within a specific time frame while expecting the best results from you. They always expect you to be fast and better each time.
You will have to work hard under a pace-setter boss to stay their good books.

5. The Under Qualified

This boss is one who is less taught than you or knows minimal about the organization and its procedures. They will rely on you to provide information they might not be aware of. But never underestimate their power because a boss is always a boss even if you leave him behind in education.
Have a close relationship with them and explain them everything they need to know. Once they get up to speed with everything, they will have you to thank.

6. The Squeezer Boss

This type of boss squeeze every last ounce of talent from the employee. They know what each employee is capable of and tend to be the best to work with. They will give you work according to your talent which will boost your resume. The problem with this kind of bosses is that they might insist on you to work overtime and even on off days.
Even though your career might take off, your life work balance will be greatly impacted. Unfortunately, there’s little you can do with this type of a boss. Your only options are to ask for a pay rise for your extra input or to find an alternative job.

7. The Intimidator

These bosses are often called dictators also. They fall back on terrorizing strategies, for example, hollering, when speaking with their employees. They will chide you on the off chance that you neglect to perform in an agreeable way.
A good way of dealing with such a boss is by making sure you do your job. Never give them a single chance to yell at you. Speak with them about the work you're doing if needed, yet don't capitulate to their terrorizing strategies. They will appreciate you for this.

8. The Unpredictable

If you have an unpredictable boss, then there’s not much that you can do. These bosses’ actions are hard to predict. Whereas they may be satisfied with something today, the same may not necessarily be true tomorrow. This means that you’ll always have to break into a sweat whenever you’re reporting to them. The only way you can try and alleviate their “unpredictability” is by ensuring that you do your work as expected.

9. The Traditionalist

These supervisors tend to stick to old organization customs, and they may bring this up during meetings. They have most likely been in the organization for quite a while and they don't warmly welcome change. Never try arguing with a traditionalist, and always be responsive to their thoughts. You never know, some of their old strategies may really work.
If there is an easier way of doing something, bring it to their attention in a kind way. They don't prefer to feel challenged. They'll get more open to your thoughts once they feel you're responsive to theirs.

10. The Perfect Boss

A perfect boss treats the employees in the workplace fairly. They are open to suggestions and are willing to give you space to do your work. They will exhort you on your vocation prospects and may enable you to accomplish your professional objectives. Moreover, their work relationship does not end in the workplace. They are constantly prepared to catch up with you on your most loved group's diversion after work hours.
Unfortunately enough, the world does not have the same number of ideal bosses as everybody would wish. On the off chance that you have a perfect boss, value their endeavors! They will leave an enormous void once they leave the organization.

5 Tips for Computer Science Students

5-tips-img
You are in college now so I am skipping the basics the go to class do your homework study for tests stay out of the hospital. These are not all important pieces of advice but I am sure you have heard them. Instead, let’s talk computer science. Here are some tips I have specially collected by talking to students who wish they’d heard them when they were students. Listen up.

  1. Seek help when you need it. Your classes are going to get harder, they are going to test your knowledge but that’s why you are there for. Some people find attending office hours or seeking extra help to be embarrassing. But these resources are there for a reason. Taking advantage of the help you are offered will not only help you prepare for future classes and learn the material better but a lot less harmful than bad grades or any other consequences of struggling.
  2. Don’t let yourself intimidated by large projects. The best thing to do, sit down a day at the assignment and break it up into smaller tasks. A lot of times it’s looking at the smaller tasks that help you realize the solution and even if it does not, you’ll only have to face one small problem at a time instead of a huge and overwhelming one.
  3. Error can be unpredictable for don’t procrastinate even if you see the solution right away. You still can’t really predict the types of errors you are going to face. It’s time to compile or if there’d logical errors when you run it. Sometimes it may be the slightest error that can be the hardest to catch. So make sure you leave yourself enough time to tackle it.
  4. Silly errors are no small things is computer science. One silly error can ruin the entire program and likewise, you are great. It is not uncommon for computer science classes to skip partial credit. If your code does not work you make it nothing for it. A more compassionate professor might throw you off 50% but the truth is that one little missing semicolon that you were too tired to find before returning your homework can be all it takes to turn an A into an F. So, don’t miss the semicolon.
  5. Stop and compile regularly. If you compile your projects on regular basis, you can solve errors as they appear and locating them would be easy because they could only appear since the last time you compiled. I know it can be annoying to get your program to a stopping point or you can do this but it’s definitely worth it. The alternative is getting all the errors at the end and there could be a lot of them. All hidden throughout your code, the code you wrote who knows how long ago and make sure you test sample code before you use it. There is nothing worse than just assuming that it works only to find out it’s the source of your problem and the one place you didn’t look.

Subscribe for more.

JSON with JAVA – Introduction to JSON – Part2

JAVA SE does not have any internal package for processing JSON data. We have to import an external library. There are many libraries available. You can choose any. I will use Json-simple1.1 here. This makes our first step, importing the lib.

Importing the lib

 Click here and download the zip file containing the jar library and follow the following steps to import it into eclipse.
1. Extract the zip file.
2. Right Click on the project folder in the package explorer, hover over Build Path and click on Configure Build Path.
step2-img
3. You will see a nice window. Go to the Libraries tab and click on Add External JARs.
step3-img
4. Navigate to the extracted jar folder, select the library and press open/ok.
5. Press ok again and you are done.

Exploring the lib

The library contains parser and data structures to process the given JSON formatted string. The parser parses the JSON data from string/Reader to its own readable form. The data structures consist of JSONObject and JSONArray Classes which store JSON Objects and JSON Arrays respectively. The library has a bunch of other classes and methods but we will confine ourselves to only these three classes (JSONParser, JSONObject, JSONArray). Within these classes, we will use few methods. Why? Because it is just to get you started with JSON. Ok, Whatever. Let’s get started.

 JSONParser

Constructor

public JSONParser()

Public methods

public Object parse (Reader);
public  Object parse (String);
public Object parse (Reader, ContainerFactory);
public Object parse (Reader, ContainerHandler);
public Object parse (String, ContainerFactory);
public Object parse (String, ContainerHandler);
public Object parse (Reader, ContainerHandler, Boolean);
public Object parse (String, ContainerHandler, Boolean);
Above mentioned methods do the same work with different approaches. We will use parse (String) in our code just to make it work easily.

JSONObject and JSONObject

We will initialize these two classes from the JSONParser object and use their following methods:
public Object get (Object); // to read
public Object put (Object, Object); // to write to a JSON object
public boolean add (Object) // to write a single entry at the end of a JSON array
public Boolean add (int, Object) // to write a single entry at int index of a JSON array
public Boolean addAll (Collection) // to write a collection of entries to a JSON array
public Boolean addAll (int, Collection) // to write a collection of entries at int index of a JSON array
To read from JSON you should know that the structure you are reading from JSON is whether a JSONObject or JSONArray and what is its name or index. We will have to pass this information in the get method.

Writing Code

Reading from JSON file “example.json”

  • Preparing the file to read from

File file = new File("example.json");
FileReader fr = new FileReader(file);
BufferedReader bfr = new BufferedReader(fr);
String jsonString = "";

while (bfr.ready()) {
jsonString += bfr.readLine();
}

  • Initializing parser

JSONParser parser = new JSONParser();

  • Obtaining the root element

JSONObject rootObject = (JSONObject) parser.parse(jsonString); // we know that the root element of our file is a JSON Object that why parsing the result to JSONObject

  • Getting the hobbies Object

JSONArray hobbies = (JSONArray) rootObject.get("hobbies");

  • Extracting the favorite books array

JSONArray favBooks = (JSONArray) rootObject.get("fav_books");

  • Traversing the JSONArray

for (int i = 0; i < favBooks.size(); i++) {
JSONObject favBook = (JSONObject) favBooks.get(i);
System.out.println(favBook.get("name") + " by " + favBook.get("author"));
}


Get the full source code here.

Writing to JSON file “example2.json”

  • Getting the file ready to write

FileWriter fwriter = new FileWriter(new File("example2.json"));
BufferedWriter bfwriter = new BufferedWriter(fwriter);

  • Initializing and populating ArrayList

ArrayList<String> fruits = new ArrayList<String>(); // Collection of entries
fruits.add("Apple"); // populating collection
fruits.add("Orange");
fruits.add("Peach");

  • Initializing JSONObject and JSONArray

JSONArray jArray = new JSONArray();
JSONObject jObject = new JSONObject();

  • Populating the objects

jArray.addAll(fruits); // collection added to json array
jArray.add(0, "Srawberry"); // a single entry added at 0 index

jObject.put("fruits", jArray); // JSON array added to JSON object

  • writing to file

bfwriter.write(jObject.toJSONString());

Get the full source project here.

Give us your feedback by commenting and by participating in the survey. You are doing great, keep it up, see you in the next post.

Introduction to JSON – Part 1

json-img
JSON is a data interchange format, frequently used for data exchange between clients and servers across the web. I am dividing this short tutorial series into three parts just to make it easy for you to understand. Part 1 is an introduction to JSON. It shows what is JSON, its structures are and how to write a JSON document. Part 2 explains How to process JSON in JAVA. The last part includes JSON Serialization. Hold your breath, a lot is coming up.
JSON, short for JavaScript Object Notation is a lightweight format which makes data exchange more than easier. It is also used to store data. JSON is language independent. For example, you can make a JSON Object in java and send it to a C# program which will gracefully handle it. JavaScript object can be converted into a JSON object and vice versa.
A JSON document can have two structures.

  • JSON Object: A name value pair or a key value pair. Names/Keys are only strings however values are of various types. Name and value are separated by a single colon (:). JSON Object is contained within the curly braces.


Name : Value,
}

  • JSON Array: An ordered sequence of values stored in square braces separated by a comma.

[
Value,
]
Types of Values: These types should be familiar to you and may not need any explanation. A value can be a

  1. String
  2. Number
  3. Bool (True/False)
  4. JSON Object
  5. JSON Array

A JSON value can also be null.
The file which contains JSON data is stored with .json extension. Following is an example document named Example.json. Study it and identify different structures and value types.
Example: Example.json
{
"first_name": "Salman",
"last_name": "Ahmad",
"gender": "male",
"age": 22,
"hobbies": [
"video games",
"drawing",
"music"
],
"fav_books": [
{
"name": "The Shallows",
"author": "Nicholas G. Carr"
},
{
"name": "Brain Bugs",
"author": "Dean Buonomano"
}
]
}
Next is How to process JSON data in JAVA. We will use this example in our code. See you there.

Who made Facebook decide to buy WhatsApp and to steal SnapChat Stories feature? 'You'

img spying facebook
A fresh report claims that Facebook is spying on its users. It knows what millions of people do on their phones. It knows what do you browse, what apps do you use, how frequently and for how long. It is gathering all the information and detailed insights of your online behavior and habits.
This information has been used to shape Facebook's product roadmap. Facebook perceived from its data analysis that its users are using WhatsApp much more frequently and for a long time so it will be a big deal to buy it. It also led Facebook to rip Snapchat's stories feature.
It's so precise that it allowed Facebook keep tabs on how many Snapchat posts users sent each day, the Wall Street Journal reports.
Onavo Protect, a free VPN app that claims to help "keep you and your data safe when you go online", has been the spying tool for Facebook for all this time. It was created by a company which is now owned by Facebook.
The app is very popular among Android and iOS users and has reportedly been downloaded by around 24 million users.
According to people familiar with the system, when Onavo Protect users browse a website or open an app, Onavo redirects the traffic to Facebook servers where the details are pushed to databases. The Facebook's product team then analyze this big data and make such big decisions.
Facebook is not alone in this spying business. Google and Apple are also keeping an open eye on its users but it is unclear that they have been using the data to improve their own product. Hmmm, they seem less selfish than FB.
However, Onavo claims that it "analyzes information about your mobile data and app use" and may share the data with "affiliates" for targeted advertising.
This setup reportedly allowed Facebook to figure out just 'how devastating an impact the rollout of Stories on Instagram has on Snapchat' popularity and growth, long before Snapchat released any of the details itself and to add Stories clones to Facebook Messenger and Whatsapp.

Reference: Wall Street Journal

Inheritance In JAVA: Example

img: Inheritance In JAVA: Example
This is the second last section of the topic Inheritance In OOP where we will study some code snippets. This study will clarify the idea of how to achieve inheritance in JAVA and how it actually works. Without wasting any time and giving length to the post for no reason, let’s start rolling.
Prerequisites: To understand these snippets you should already know what inheritance is. If you don’t, don’t worry. I have a blog post, go here.
Overview: I have written a program named Example which depicts real life inheritance properties like a relationship between child and parent, child access to parent properties etc. The program consists of 4 very simple java classes which are extremely easy to understand. However, if you face any issue ping me in comments. I am always there for you. ExampleBobJohn, and Stephen. The bold faced letters are not names of some persons, in fact, these are names of classes which we are going to study here.
In Java, to establish a child parent relation between two classes, the keyword extends is used at the class declaration time. The child class name is written at the left of the keyword and the parent class name is written on the right side. Syntax:
Child_Class_Name extends Parent_Class_Name
Let’s cast a glance over the access modifiers.
Public: members specified with the public keyword are accessible anywhere in the program using the class object.
Protected: Members modified by protected keyword are accessible within its own class and the child classes without using any object of the parent class.
Privateprivate members are available within the scope of only its own class. 

Stephen.java
public class Stephen {
protected int money = 5000;
}

This is the simplest and easiest class I think I have ever seen. As you can see, it only has a single integer data member named money which is initiated to 5000. This class does not extend any class it means that it does not have any parent class. In our story context, Stephen is the grandfather of Bob and have $5000 in his bank account. The variable money is qualified by the keyword protected which means that this variable is accessible in this class and its child classes only. It (variable money) is inaccessible by the object (Object of Stephen Class). Simple.
Bob.java
public class Bob extends Stephen{
protected String eyeColor = "green";
protected String car = "Bob's BMW";

private String mailbox = "Bob's Mailbox";
public void drive() {
System.out.println("Bob is driving: " + car);
}
public void eyeColor() {
System.out.println("Bob's EyeColor: " + eyeColor);
}
public void money() {
System.out.println("Bob says: my dad have $" + money);
}
}

Bob class extends Stephen class (Bob is a child of Stephen). It has two protected String variables, eyeColor and car and one private String variable, mailbox. What does it show? It shows that the child classes can have or use the eyeColor and car properties while they can't use the mailbox variable. In real life, a child can inherit eye color from his/her parent and can also use their parent’s car but they can’t read their parent’s mailbox unless they are allowed to. While writing this example, I tried to be as real as I could because I think it makes it easier to understand. There are three simple public functions which are accessible through the class object. These functions are self-explanatory.
John.java
public class John extends Bob{
public void eyeColor() {
System.out.println("John's eyecolor: " + eyeColor); // note the eyeColor is from 'Bob' Class
}
public void drive() {
System.out.println("John is driving: " + car); // car is also from Bob class
}
public void money() {
System.out.println("John says: My grandpa have $" + money); // money is from Stephen class
}
}

Class John has nothing more than three functions which simply prints some string with some variables (eyeColor, car, money) from its parent classes. You can see that John is a child of Bob and can access private and public members of Bob class. However, it is using money variable from Stephen class which it does not extends. What the heck is this? Is this correct? Well, yeah! It is correct. The thing is John extends Bob and Bob extends Stephen class so John is also a child of Stephen. Kind of grandchild. This is called multi-level inheritance.

Example.java
public class Example {
public static void main(String[] args) {
Bob bob = new Bob();
John john = new John();

bob.drive();
bob.eyeColor();
bob.money();
john.drive();
john.eyeColor();
john.money();
}
}

Output: 
Bob is driving: Bob's BMW
Bob's EyeColor: green
Bob says: my dad have $5000
John is driving: Bob's BMW
John's eyecolor: green
John says: My grandpa have $5000

This is the final main class which includes the main function. It simply creates objects of Bob and John classes and calls some of their public functions. Easy. Look at the output and figure out how does it works. It is your home task. If you find yourself in trouble, contact me via comments below.
In coming section, we will discuss why did we study inheritance? And where to use it.  Subscribe using the subscribe button up there in the toolbar and we will notify you when the post is ready. If you have any questions or suggestions, please leave in the comments below and also mark one of the options in the survey popup. 
Stay tuned.

Inheritance in OOP: Introduction

inheritance in oop-image

In the previous section, we talked about what Object-Oriented Programming is and what are its key concepts or features. We defined them in a very brief and formal way. As I promised that we will discuss each of those in details, here it is. I will try to be as natural as possible.
Inheritance is that feature of Object-Oriented programming which allows developers to borrow code from a prototype (class) and extend it, by adding more properties to it and behaviors to manipulate those properties. It reduces the size of the code with a big margin by creating is-a relationships between objects. This line might sound confusing but don’t worry. You will see in the coming section that how it reduces size of the code. The more common properties and behaviors a program have, the more usable inheritance will be. It allows you (the developer) to implement the real world parent-child hierarchy in a computer in a robust way. Here, I will tell you all I know about inheritance, how to implement it in Java and then where to use it.
Above, I said that inheritance allows developers to implement the parent-child hierarchy in computers like the real world. Inheritance is actually based on the parent-child concept. It has the terms ‘parent’ and ‘child’, which we will define each in the context of OOP but first let me ask you a question. Who is a parent and who is a child, in the real world?  I am sure you will have an answer but if you don’t have, I am happy then that my posts are being read far from the earth. Alright, let’s take our topic seriously.
A child (human) inherits traits from their biological parents like their physical appearance. Children also have access to the property of their parents and have the right to use it unless the property is private to their parents. For example, let’s create a scenario, an inheritance story. John is (a) son of Bob. He resembles his father in many ways because he is his son. Gregor Mendel has explained this through his work on pea plants. Anyhow, He (John) lives with his dad and often drives his car, use his shoe polish, towel etc. But John does not have access to his dad’s private mailbox or Facebook account or anything else which is private to his dad. John also goes to school and gets assignments from his teacher. His dad loves him and helps him often times to complete the assignments but he does not take him with himself to the parties at bar cuz those are private (not for kids sort of party) and John is only 13.
Note the boldface is-a relationship and the things John have access to or what his father does and does not for him. You might have noticed that John can use or know about only the non-private things that his dad own or does. Why? Because they have a relationship between which have its own restrictions. Nobody else can use those property (i.e. those are protected). Now, let’s see these terminologies or concepts or whatever you want to call it, in Object-Oriented Programming.
If you are here, it means that you know what a class is and what an object is. In case you don’t, go here.
In inheritance, classes have is-a relation. The class, which inherits from other class(es) is called child class aka subclass, derived class or extended class and the class which the child inherits from is called parent class or super class or base class. We will use child-parent notation throughout this blog. Like the real world, a class can have many child classes and a child class can have many parent classes. You will see a single example for each case in the next section. The parent class can have private, protected and public members and so can have the child class. The child or derived class have access only to non-private (protected and public) members of its parent class(es). Different languages support different types of inheritance. For example, Java supports single and multi-level inheritance while C++ supports single, multiple and multi-level inheritance. Each language has its own syntax and keywords but the basic concepts are the same. You will need to master only one and then you will be able to go with anyone with a very little work.

Types of Inheritance:

inheritance types-infographic
You might be familiar with the words single, multiple and multi-level inheritance. If you are not, no worries. These are different types of inheritance which you are going to learn in this section. Many authors/programmers include more other types such as hierarchical inheritance, multi-path inheritance and hybrid inheritance in their introductory words to the types but I am not including any other than the basic three types here. In my opinion, the other types are formed by combining the basic types (single, multiple and multi-level). Learn the basics well, it will be easy to learn the rest.
Do you remember John, the main character of our inheritance story? Let’s add more people to his family.
John have a caring mom, Sarah and a loving grandpa, Stephen. We do not need to talk about what they can do or what they have for now. To depict my point clearly, I am including an infographic.
Notice that:

  • The child class in Single Inheritance has a single parent.
  • The child class in Multiple Inheritance has more than one parents (at the same level).
  • The child class in Multi-level Inheritance has a parent and the parent class itself inherits from another parent class. 

Bullets, above are not standards. Variation are possible such as in single inheritance a parent class can have many child classes and a child class can have multiple parent classes at the same level in multi-level inheritance. I hope it makes sense to you.
Alright, we are done for today. You are doing great. Keep learning, sky is the limit. There are great content out there which discuss inheritance further in details. I will encourage you to go for it and study every detail until you feel comfortable with it while coding. You can find some helpful stuff here.
Alright, we are done for today. You are doing great. Keep learning, the sky is the limit.
Next is a How To tutorial where we will talk about how to achieve inheritance in Java, its types and what keywords to use, followed by a very important section where we will discuss where to use which type of inheritance in real projects. Subscribe using the subscribe button up in the toolbar and we will notify you when the tea is ready. If you have any questions or suggestions, please leave in the comments below and also mark one of the options in the survey popup.
Happy coding.

What is Object-Oriented Programming? The concept of Class and Objects

what is oop-image
Object-Oriented Programming is a powerful way to address the task of programming. Programming methodologies have improved dramatically since the invention of the computer, primarily to support the growing complexity of programs.
For example, when computers were first invented, programming was done by toggling in the binary machine instructions using the computer's front panel. As long as programs were just a several hundred instructions long, this way worked. As programs grew, assembly language was invented so that a programmer could deal with bigger, more complex programs, using symbolic representations of the machine instructions. As programs continued to grow, high-level languages were introduced that gave the programmer more tools with which to handle complexity.
The 1960s gave birth to structured programming. This is the approach supported by languages such as C and Pascal. The use of structured languages made it possible to write somewhat complex programs fairly easily. Structured languages are characterized by their support for stand-alone subroutines, local variables, rich control constructs, and their lack of dependence upon the GOTO. Although structured languages are a powerful tool, even they reach their limit when a project becomes excessively large. Consider this: At each milestone in the development of programming, techniques and tools were created to allow the programmer to deal with increasingly greater complexity. Each step of the way, the new approach took the best elements of the previous methods and moved forward.
Earlier to the invention of Object-Oriented Programming, many projects were touching the point where the structured approach no longer worked. Object-oriented methods were created to help programmers overcome these limitations. We can say that Object-Oriented programming is inherited from structured programming. It took the best traits/ideas of structured programming and merged them with several new concepts. The result was a different way of organizing a program. In the most general sense, a program can be organized in one  of the two ways:

  1. around its code 
  2. around its data 

Using only structured programming techniques, programs are typically organized around code. This approach can be thought of as "code acting on data." Let's look at an example, a program, written in C (a structured programming language) is defined by its functions, any of which can manipulate data of any type used by the program. Object-oriented programs work the other way around. They are  organized around data, with the key principle being "data managing access to code." In an object-oriented language, you define the data and the routines that are permitted access that data. Thus, a data type defines exactly the ways in which that data can be manipulated. To support object-oriented programming, all OOP languages have three features in common: encapsulation, polymorphism, and inheritance. Let's explore each.

  • Encapsulation


Encapsulation is the mechanism that combines the data and the functions which manipulate that data, and keeps both safe from tampering and misuse. In an object-oriented language, functions and data may be bound together in such a way that a self-contained black box is created. We can only give input to and receive output from the black-box without knowing what is going inside the box. When functions and data are joined together in this manner, an object is formed. In other words, an object is the device that supports encapsulation. 
Within an object, functions, data or both may be private to that object or public to whole program. Private data of an object is only known to functions of that object and private functions are only accessible within the object. Public members (functions and data) are visible to outside of its objects.

  • Polymorphism

Object-oriented programming languages support polymorphism, which is described by the slogan "one interface, multiple methods." In simple words, polymorphism is the property that allows one interface to control access to a general class of actions
For example, you might have a program that specifies three distinct types of stacks. One stack stores integers, one character and the last floating-point values. You can declare functions with the same names, push() and pop() for all three stacks because polymorphism allows you to. You will create three specific variants of these functions, one for each type of stack, but names of the functions will be the same. The compiler will automatically select the appropriate function based on the data being stored.
Polymorphism helps in reducing the complexity of the program by allowing the same interface to be used to access a general set of procedures. It is the compiler's job to select the specific function as it applies to each state. This selection process is automatic and you, the programmer, do not need to participate. You need only to remember and to utilize the general interface.

  • Inheritance

Inheritance is the process by which one object of a class can acquire the resources/properties of another object of another class. This is important because it promotes the idea of classification and largest data is made manageable by hierarchical classifications.
You can take biological classification as an example. For example is Human part of mammalia class, which in tern is part of subphylum vertebrata, which is under the phylum chordata, and so on. Animals in each class share some or more common traits. Without the use of classifications, each object would have to define explicitly all of its characteristics. However, through the use of classifications it an object defined only those properties which make is unique in its gener or class. It is inheritance which makes it possible to for an object to be a specific instance of a general class. As you will see in your programming journey, inheritance is an important feature of object-oriented programming.

How To Improve Logic Building Skills In Programming?

how to Improve logic building skills in programing-img
[DISCLAIMER]: Everything in this article is my own opinion and these are not standards. Feel free to criticize.
I frequently see beginners asking questions in forums like 'how can I improve my logic building skills' or 'how to think logically or something like 'how to think like a programmer' and blah, blah. If you have similar questions in your mind then follow along. I know, I am not the best but I will share my experience and I hope you will find it helpful.

Programming Can Cause Health Problems: Read Some Health Tips Here

"He who has health has hope, and he who has hope has everything."
I am writing this article with no intentions of making you feel guilty about your lifestyle. I just want to share a few tips which I use myself which helps me to stay healthy. One should have good cognitive abilities to become a good programmer, in my opinion, but poor physical health can lead to an increased risk of developing mental health problems. A surprising number of developers suffer from health issues due to their sedentary lifestyle.
We, I mean developers ;) ignore little things which can bring big changes. We forget that it's the little things that matter most.
In my case, programming has given me fun and money but some health problems too. I don't want and I am sure nobody wants to take medicine which tastes like shit or something else like this. Last year I was reading I decided to change my lifestyle. Last year I found the book, The Healthy Programmer, in the library. I read it and I find it very helpful. Here, I will share some tips which I follow.

  • Exercise on regular basis:

Everyone knows that exercise is key to good health. You can find a lot of research which shows how exercise affects health. 
There is no need to go to a gym and lift heavy weights but doing some form of exercise pays in the long run. exercising regularly keeps your body fit and improves your physical and mental health. If you walk to your workplace or go up and down on stairs frequently, you are almost done. You can also do some exercise even while you are on your desk. You don't need to leave the desk and go to a walking track or a park. It will keep you fresh and focused.

  • Don't stay up all night:

Programming is a back-breaking and taxing job. It sometimes needs you to stay awake and on the ball all the night. But making it into a habit can screw up your health. A study showcased by the APSS (Associated Professional Sleep Society) suggests that lack of sleep adversely impacts one's retention capacity and the ability to solve problems. Sleep deprivation can impair your brain activity and can cause cognitive dysfunction. Sleep makes you feel better, but its importance goes way beyond just boosting your mood or banishing under-eye circles. Adequate sleep is a key part of a healthy lifestyle and can benefit your heart, weight, mind, and more. But sleep all day or stay up all night is not the goal. I personally don't like the thought of 8 hours a day of sleep. The goal is to think big and develop bigger. But once the focus is lost, then it's time to go to sleep. 

  • Take proper food:
Programmers drive themselves to unhealthy conditions just in the interest of their goals. They eat at restaurants very often or grab candy in the office  because of the lake of time. They don't have time for lunch. All these are nothing but bad habits. Take a closer look at your dietary habits and use the latest science to create an eating plan that is personalized for you.  Creating a balanced diet is very simple. WHO, US Department of Health and Human Services and US Department of Agriculture recommend that a healthy daily diet consists of the following components: 30% grains and starches 30% fruits and vegetables 16% dairy 16% lean protein (meat, fish, eggs etc) 8% fatty and sugary foods There is no perfect diet but it is a good idea to rotate through the categories. Eat but with care.


  • Move somewhat

It is important to be conscious of your posture. The number of people suffering from injuries due to bad posture is increasing. Dr. Hedges recommends setting for no longer than 20 minutes. The alternative is standing desk. In the beginning, it seems difficult for our body to accept the new setup. Therefore take the incremental approach and gradually increase the time you spend on standing desk. But standing for longer than 20 minutes is also not recommended. Also, follow 20-20-20 rule. After 20 minutes of screen time, look for 20 seconds at objects which are 20 feet away. This will relax your eyes and avoid eye redness.

The point is, Change if it hurts and walk when you can, just keep your body moving.

  • Make a good posture
Bad posture is something that many developers ignore unless they feel the pain. Wrist pain, back pain, neck pain, joints pain etc might be caused by the way you sit, stand or type on the keyboard. The distance between the screen
and your eyes and the angle also matters. 
Programmers and pianists have a lot in common. They spend hours a day sitting in a chair in front of the keyboard. Only a few of them might know how to position their bodies for this task. 
The correct posture depends on the individual. The position which works for me, might not work for you. There are no specific ways you can follow, but here are some very common rules that work for everyone:
* Adjust your chair height so that your hips are level with your knees and you do not slide backward or forward in the seat.
* Adjust your desk height so that your elbows are level with your wrists. 
* As you sit in your chair, ensure that you are placing even amounts of weight on your front, back, and side supports.
* One of the important aspects of posture is keeping your feet on the ground. If you are good with your posture but your feet are above the ground, then you may want to use a small footrest to prop up your feet.


How To Protect Your Online Privacy? Try To Keep Your Private Things Private

Being online is part of the life now. People are online from home, school, library, roads and washrooms. Sitting on a toilet and chatting with a buddy or playing games is a habit of many. Do you know what you actually do when you browse the Internet? Yes ? No ? Alright, Lemme tell you. You just access someone's else computer. But the same can happen with you. Once you get on a network, you raise a security risk for your digital life as well as your real life events. Are you sure that you are the only one in authority who can use your resources? (By resources I meant PC, Smartphone, Webcam, Mic or anything that can be on the Internet). Are you really sure that nobody is spying on you? Do you have someone or something which can tell you 'Watch out'? If you have, is it trustworthy?
Hmmm, So what to do? Here

10 Failed 10 Successful


title image
dr suess

Dr Suess 

The Cartoonist, Writer and Animator

Published over 60 books including The Cat in the Hat and Green Eggs and Ham but he was rejected a shocking 27 times before publishing his first book And to Think That I Saw It on Mulberry Streets.
Quotes: 
Today you are you! That is truer than true! There is no one alive who is you-er than you.
You have brains in your head. You have feet in your shoes. You can steer yourself any direction you choose. 
The more that you read, the more things you will know. The more that you learn, the more places you'll go.
jk rowling

J.K Rowling  

The Novelist, Screenwriter and film producer 

Best known as the author of the Harry Porter, fantasy series 
The Harry Porter manuscript was rejected by 12 publishers before Bloomsbury picked it up. Now the series has been translated into 73 languages and has earned over $400 million dollars in book sales.

Quotes:
We do not need magic to transform our world. We carry all of the power we need inside ourselves already.
If you want to know what a man's like, take a good look at how he treats his inferiors, not his equals.
It is our choices...that show what we truly are, far more than our abilities. 
james-dyson

James Dyson 

The Inventor, Industrial designer and founder of Dyson company 

Best known as the inventor of the Dual Cyclone bagless vacuum cleaner  
He stated that:
There are countless times an inventor can give up on an idea. By the time I made my 15th prototype, my third child was born. By 2,627, my wife and I were really counting our pennies. By 3,727, my wife was giving art lessons for some extra cash. These were tough times, but each failure brought me closer to solving the problem. 
 Quotes:
Enjoy failure and learn from it. You can never learn from success.
After the idea, there is plenty of time to learn the technology.
There is nothing wrong with things taking time.
steven-spielberg

 Steven Spielberg 

Director, Screenwriter and Producer 

He is one of the founding pioneers of the New Hollywood era and one of the most influential personalities in the history of film, perhaps the best-known director of Hollywood.
He was rejected for 3 times by The University of Southern California due to poor grades in high school but later the university awarded him with an honorary degree. Steven Spielberg directed 51 films and won 3 Oscars. 

Quotes:
I don't dream at night, I dream at day, I dream all day, I'm dreaming for a living.
All of us every single year, we are a different person. I don't think we are the same person all our lives.
People have forgotton how to tell a stroy. Stoties don't have a middle or an end any more. They usually have a begining that never stops beginning. 
jack-canfield

 Jack Canfield

Author, Motivational Speaker and Entrepreneur

Canfield and his co-author faced 144 rejections from publishers in a period of 14 months. His book Chicken Soup for the Soul the third best-selling book in US during mid 1990s. More than 500 million copies has been sold in over 40 languages.

Quotes:
Decide what you want. Believe you can have it. Believe you deserve it and believe it's possible for you.
Don't worry about failures, worry about the chances you miss when you don't even try.
Everything you want is the other side of fear. 
honda

 Soichiro Honda

Founder of Honda Motor Co., Ltd

His factory was hit by a bomb in World War 2. He rebuilt it. Then an earthquake leveled it. He denied to admit defeat and reconstructed it and now you know where the company stands.

Quotes:
Instead of being afraid of the challenge and failure, be afraid of avoiding the challenge and doing nothing.
Mnay people only dream about success, while for me success is to overcome permanent failures.
Success represents the 1% of your work, which results from the 99% that is called failure.
stallone

Sylvester Stallone

Actor, Filmmaker and Screenwriter

Well known as Rocky Balboa and John Rambo

Stallone born with some parts of his face paralyzed. He was rejected 1500 times (who counted this idk) by everyone in the film industry that he could get a meeting with. 
He became the third person in history after being nominated for Best Original Screenplay and Best Actor award for the same film, after Charlie Chaplin and Orson Welles.

Quotes:
Life is not about how hard of a hit you can give. It's about how many you can take and still keep moving.
You must fail a hundred times to succeed once. 
 Don't discuss your dreams, pursue them.

edison

Thomas Alva Edison

The inventor

Ameria's greatest inventor

Thomas Edison failed 10,000 times before successfully inventing a long-lasting and highly efficient lightbulb.

Quotes:
The most famous and very motivational quote which is one of my favorite quotes
I have not failed, I have just found 10,000 ways that won't work.
Genius is one percent inspiration and ninety-nine percenet  perspiration.
 Opportunity is missed by most people because it is dressed in overalls and looks like work.
Our greatest weakness lies in giving up. The most certain way to seccceed is alway to try just one more time.
steve jobs

Steven Paul Jobs 

The Inventor, Businessman and Industrial designer

Co-Founder and CEO of Apple Inc, CEO and majority shareholder of Pixar and Founder, member of The Walt Disney Company's board of directors and CEO of NeXT

Quotes:
Innovation distinguishes between a leader and a follower.
Sometimes when you innovate, you make mistakes. It is best to admit them quickly, and get on with improving your other innovations.
 Design is not just what it looks like and feels like. Design is how it works.
My favorite things in life don't cost any money. It's really clear that the most precious resource we all have is time.
I'm convinced that about half of what separates the successful entrepreneurs from the non-successful ones is pure perseverance. 

bill-gates

 William Henry Bill Gates

Business magnate, Author and Investor

Co-Founder, CEO and Chief Software Architect at Microsoft

Bill Gates was dropped out by Harvard University. The business, Traf-O-Data he was co-owner of, failed. Driven by his passion for computer programming, Gates built what would become the world's largest software company. Microsoft went public in 1986, and by the next year its rising share price made then-31-year-old Gates the world's youngest self-made billionaire. An investor in the initial public offering would have seen a return of 30,207 percent. 
 Quotes:
If you can't make it good, at least make it look good.
I really had a lot of dreams when I was a kid, and I think a great deal of that grew out of the fact that I had a chance to read a lot.
Technology is just a tool. In terms of getting the kids working together and motivating them, the teacher is the most important.
Don't compare yourself with anyone in this world. If you do so, you are insulting yourself.
Patience is a key element of SUCCESS.


Translate