Computer Science, asked by Anonymous, 1 year ago

list 2 main principles of OOPS and explain them


Anonymous: means you are also fake
Anonymous: tell em what you will do
Anonymous: means
Anonymous: baby why you are angry
Anonymous: your answer is not visible plz answer again
Anonymous: why no answer is visible

Answers

Answered by siddhartharao77
1
Here are the 2 main principles of OOPS:

(1) Inheritance

(2) Encapsulation


(1) Inheritance:

= > It is the property of deriving the new class from old one.

= > Old class is known as superclass and the new class is known as the subclass. 

= > The keyword extend is used by the subclass to inherit the properties of the superclass


Ex:

class Quora
{
public void Rank()
{
System.out.println("Brainly Guru");
}
}

public class Brainly Extends Quora
{
public void SpecialRank()
{
System.out.println("Core Moderator");
}
public static void main(String args[])
{
Brainly a = new Brainly();
a.Rank();
a.SpecialRank();
}
}


Output:

Brainly Guru
Core Moderator





(2) Encapsulation:

= > Wrapping the data as a single unit.

= > It controls the way data is modified.

Ex:

class Some
{
 
private String student;

public String getName()
{
return student;
}


public void setName(String student)
{
this.student=student;
}
}


public class Demo
{
public static void main(String[] args)
{
Some s = new Some();
s.setName("Siddhartha");
System.out.println(s.getName());
}
}

Output:

Siddhartha.




Hope this helps!

Anonymous: now what happend why are you not talking to me
siddhartharao77: Yes...ur right... :-)
siddhartharao77: please...dont chat here
Anonymous: i just want to know that you know SwtTanya
siddhartharao77: dont report the answers wantedly @rohankalra
Anonymous: I want her naked pics
Anonymous: want to lick her boobs
Anonymous: lick vagaina
Anonymous: and all about orgasim but she refused
Anonymous: Hello , shrutig14 I am very very sport for your miss convenience , my cousin brother was talking with you last night with my phone and my account , he had talk with other 2 girls also who was live at that time . I am sorry if he had used any wrong word or any thing . Please reply , and forgive him . Thanks You
Similar questions