Thursday, October 20, 2016

Inheritance in Java

Defination :

Inheritance can be defined as the process by which a class can acquires the properties(instance variables and methods) of another class called super class. The class which is inheriting the properties is called child class or sub class or derived class and the class whose properties are being inherited is called parent class or super class or base class. The 'extends' keyword is used to inherit the properties of a class.

How to create inheritance?

class Person
{
      int age;
      String name;
}
class Student extends Person
{
      int rollNo;
      public void print()
      {
             System.out.println(age);
             System.out.println(name);
             System.out.println(rollNo);
      }
}

In sub class we need to specify only new variables and methods that are not a part of the super class.

How to Solve initramfs Problem in ubuntu?


mount: mounting /dev/loop0/ on /root failed : Invalid argument
mount: mounting /dev on /root/dev failed: No such file or directory
mount: mounting /sys on /root/sys failed: No such file or directory
mount: mounting /proc on /root/proc failed: No such file or directory
Target filesystem doesn' t have requested /sbin/init
No init found. Try passing init = bootarg.

BusyBox v1.21.1 (Ubuntu 1:1:21.0-1ubuntu1) built-in shell (ash)
Enter 'help' for a list of built-in commands

(initramfs) _

To solve this problem you must follow the following steps:

1. When you start your computer, it will ask you to select the operating system. Select Ubuntu.
2. When your computer exits from the OS choosing screen, press 'shift' key from your keyboard constantly.
3. Then one screen will appear from boot loader. Don't do anything with that, just press 'e' key from your key board.
4. Then a set of commands will be displayed which are used to boot ubuntu.
5. In those boot commands find the lines that contains 'ro quiet splash' and change the 'ro' word to 'rw' (read write). It will now looks like 'rw quiet splash'.
6. Press the key to boot at the bottom, or press F10, or press ctrl+X. Now boot loader will boot ubuntu with modified boot commands.
     
     However that 'rw' word wont be saved and at the next boot you will have the same problem again. So you need to edit the /etc/default/grub file.

7. Type 'sudo gedit /etc/default/grub' in terminal and hit enter.
8. Find the line which looks like 'GRUB_CMDLINE_LINUX_DEFAULT="quiet splash" '.
9. Change it to 'GRUB_CMDLINE_LINUX_DEFAULT="rw quiet splash" '.
10. Now save the file and close the terminal. When you reboot your computer it will boot normally.