Professional Documents
Culture Documents
AOOP-Lect 8
AOOP-Lect 8
Practice
Solving Building
1 Practice More
By Zohair Ahmed
Wrapper Classes
▸Boxing:It is manual method to convert primitive type data into non-primitive type .
▸int num=7;
▸Integer num1=new Integer(8); //boxing
▸AutoBoxing:It is automatic conversion of primitive type data into non-primitive data type.
▸int num3=5;
▸Integer num4=num3; //autoboxing
▸AutoUnBoxing:It is automatic conversion of non primitive type data into primitive data type.
▸int num5=num4; //autounboxing
By Zohair Ahmed
Abstract Keyword
▸Abstraction is a process of hiding the implementation details and showing only functionality to the
user.
▸Abstract method
▸Instead of defining the method, we can declare the method. - If we put a semicolon at the end of a
method, it means that you only declare the method like: public void drive();
▸ This method does not contain any features and you will not be able to create an object of it. - You
need to add an abstract keyword to only declare a method.
▸Abstract class
▸Abstract methods can only be defined in an abstract class.
▸We need to add an abstract keyword before a class to make it an abstract class.
▸Objects of an abstract class can not be created.
▸If you are extending an abstract class, then it is compulsory to define all abstract methods.
▸It is not necessary that an abstract class should have an abstract method
▸Abstract class can have an abstract or a normal method or both. - An abstract class can have more
than one abstract method.
▸Concrete class: A class other than an abstract class is known as a concrete class. - An object of a
concrete class can be created.
3
By Zohair Ahmed
Abstract Keyword
abstract class car {
abstract void engine();
By Zohair Ahmed
Interfaces interface A {
▸If class only abstract methods use an
void show();
void settings();
interface, Interface is not any class. }
▸Every method in an interface is public and class B implements A{
public void show() {
abstract by default. System.out.println("In Show A");
▸We cannot instantiate an interface. - Interface }public void settings() {
System.out.println("the config and settings");
only shows the design and it does not provide }
}
public class test {
public static void main(String[] args) {
B obj = new B();
obj.show();
obj.settings();
obj.run();
}
}
7
By Zohair Ahmed