EvoNext
LESSON 10: Creating objects in java ✳️An object is a basic unit of Object-Oriented Programming and represents the real life entities. It consists of:- ⚜️State means the attributes. ⚜️Behavior…
LESSON 11: ENCAPSULATION
✅Encapsulation is defined as the wrapping up of data under a single unit. It is the mechanism that binds together code and the data it manipulates.
Another way to think about encapsulation is, it is a protective shield that prevents the data from being accessed by the code outside this shield.
Following is an example that demonsrates how to achieve encapsualtion in java:
/* File name : EncapTest.java */
join: »https://t.me/PROGRAMINGLANGUAGES1
✅Encapsulation is defined as the wrapping up of data under a single unit. It is the mechanism that binds together code and the data it manipulates.
Another way to think about encapsulation is, it is a protective shield that prevents the data from being accessed by the code outside this shield.
Following is an example that demonsrates how to achieve encapsualtion in java:
/* File name : EncapTest.java */
public class EncapTest {
private String name;
private String idNum;
private int age;
public int getAge() {
return age;
}
public String getName() {
return name;
}
public String getIdNum() {
return idNum;
}
public void setAge( int newAge) {
age = newAge;
}
public void setName(String newName) {
name = newName;
}
public void setIdNum( String newId) {
idNum = newId;
}
}
// more organized source codes at: https://t.me/java_learntocodejoin: »https://t.me/PROGRAMINGLANGUAGES1
Telegram
Front End Development
Front End Development tutorials
https://t.me/PROGRAMINGLANGUAGES1
yt >https://youtu.be/TssMp7T0Ur4
https://t.me/PROGRAMINGLANGUAGES1
yt >https://youtu.be/TssMp7T0Ur4
👍2
Q!!: Which among the following best describes encapsulation?
Anonymous Quiz
13%
a way of combining various data members into a single unit
18%
a way of combining various member functions into a single unit
51%
a way of combining various data members and member functions into a single unit
18%
NONE
😍Dear members our channel, How are you doing? 😇
i hope , you all doing well.👍
Our CEO 🤓 has great intention to help you all in all. He's doing his best to help our family, members of this channel. If any of you have intention to work for shared future💪 and have good inclination in the staff we engaged in feel free to inbox us.
He prepared member channels for simplifying amount of posts in this channel so,you can use one of them as important:
For Java » https://t.me/java_learntocode
For html » https://t.me/learncodea
For SQL » https://t.me/SQL_learn_to_code {coming soon}
and Meet skilled programmers here >👉 http://t.me/learntocodecpp
" Thanks for your support"
i hope , you all doing well.👍
Our CEO 🤓 has great intention to help you all in all. He's doing his best to help our family, members of this channel. If any of you have intention to work for shared future💪 and have good inclination in the staff we engaged in feel free to inbox us.
He prepared member channels for simplifying amount of posts in this channel so,you can use one of them as important:
For Java » https://t.me/java_learntocode
For html » https://t.me/learncodea
For SQL » https://t.me/SQL_learn_to_code {coming soon}
and Meet skilled programmers here >👉 http://t.me/learntocodecpp
" Thanks for your support"
👍1
✍🏻✍🏻......🍃🍃🍃......✍🏻✍🏻
Q: Identify the corrected definition of a package.
Q: Identify the corrected definition of a package.
Anonymous Quiz
29%
a collection of classes
11%
a collection of tools
52%
a collection of classes and interfaces
8%
a collection of interfaces
think-python-2nd.pdf
4.2 MB
Description: material for Python for those only , asking python books‼️
Size: 4.2 MB
credit: Mohammed🙏🙏
👉https://t.me/PROGRAMINGLANGUAGES1
Size: 4.2 MB
credit: Mohammed🙏🙏
👉https://t.me/PROGRAMINGLANGUAGES1
EvoNext
LESSON 11: ENCAPSULATION ✅Encapsulation is defined as the wrapping up of data under a single unit. It is the mechanism that binds together code and the data it manipulates. Another way to think about encapsulation is, it is a protective shield that…
LESSON 12: POLYMORPHISM
The word polymorphism means having many forms. In simple words, we can define polymorphism as the ability of a message to be displayed in more than one form.
Types of polymorphism
In Java , polymorphism is mainly divided into two types:
i.Compile-time Polymorphism
💎This type of polymorphism is achieved by function overloading or operator overloading. But Java doesn’t support the Operator Overloading.
ii.Runtime Polymorphism
❤️🔥It is a process in which a function call to the overridden method is resolved at Runtime. This type of polymorphism is achieved by Method Overriding.
>💗 Java program to demostrate polymorphism
The word polymorphism means having many forms. In simple words, we can define polymorphism as the ability of a message to be displayed in more than one form.
Types of polymorphism
In Java , polymorphism is mainly divided into two types:
i.Compile-time Polymorphism
💎This type of polymorphism is achieved by function overloading or operator overloading. But Java doesn’t support the Operator Overloading.
ii.Runtime Polymorphism
❤️🔥It is a process in which a function call to the overridden method is resolved at Runtime. This type of polymorphism is achieved by Method Overriding.
>💗 Java program to demostrate polymorphism
class Parent {
// Method of parent class
void Print()
{
// Print statement
System.out.println("parent class");
}
}
// Helper class
class subclass2 extends Parent {
// Method
void Print()
{
// Print statement
System.out.println("subclass2");
}
}
// Class 4
// Main class
class GFG {
// Main driver method
public static void main(String[] args)
{
// Creating object of class 1
Parent a;
// Now we will be calling print methods
// inside main() method
a = new subclass1();
a.Print();
}
}❤1
Q: The ability to define more than one function with the same name is called—-;
Anonymous Quiz
13%
Inheritance
16%
Abstraction
67%
polymorphism
4%
Encapsulation
👍2
Q: Which one is runtime polymorphism?
Anonymous Quiz
43%
MethodeOverridng
32%
MethodeOverloading
21%
Both
4%
NONE
👍2
EvoNext
WHAT IS THE CORRECT OUTPUT OF THE SNIPPET CODE?
LOOK THE QUESTION ABOVE: ____
Anonymous Quiz
21%
I am a person
49%
I am a student
12%
I am a student I am a person
18%
I am a person I am a student
👍5
EvoNext
LESSON 12: POLYMORPHISM The word polymorphism means having many forms. In simple words, we can define polymorphism as the ability of a message to be displayed in more than one form. Types of polymorphism In Java , polymorphism is mainly divided…
LESSON 13: INHERITANCE
⚜️Inheritance is one of the basic concept in object
orientation in which a new class is created by
absorbing an existing class’s members and
embellishing them with new or modified capabilities.
✅ The existing class is called the superclass, and the
new class is the subclass.
Syntax for inheritance
class SubClassName extends SuperClassName{};
Why And When To Use "Inheritance"?
- It is useful for code reusability: reuse attributes and methods of an existing class when you create a new class.
Let's explore by using sample code:-
⚜️Inheritance is one of the basic concept in object
orientation in which a new class is created by
absorbing an existing class’s members and
embellishing them with new or modified capabilities.
✅ The existing class is called the superclass, and the
new class is the subclass.
Syntax for inheritance
class SubClassName extends SuperClassName{};
Why And When To Use "Inheritance"?
class Vehicle {
protected String brand = "Ford"; // Vehicle attribute
public void honk() { // Vehicle method
System.out.println("Tuut, tuut!");
}
}
class Car extends Vehicle {
private String modelName = "Mustang"; // Car attribute
public static void main(String[] args) {
// Create a myCar object
Car myCar = new Car();
// Call the honk() method (from the Vehicle class) on the myCar object
myCar.honk();
// Display the value of the brand attribute (from the Vehicle class) and the value of the modelName from the Car class
System.out.println(myCar.brand + " " + myCar.modelName);
}
}
"thanks all!🙏"Qs: In java , which key word is used to show inheritance in a class?
Anonymous Quiz
14%
super
9%
final
61%
extend
13%
implements
4%
NONE
❤1
EvoNext
LESSON 13: INHERITANCE ⚜️Inheritance is one of the basic concept in object orientation in which a new class is created by absorbing an existing class’s members and embellishing them with new or modified capabilities. ✅ The existing…
LESSON 14: ABSTRACTION and INTERFACES
🔱 Abstraction is the property by virtue of which only the essential details are displayed to the user. The trivial or the non-essential units are not displayed to the user. Ex: A car is viewed as a car rather than its individual components
✳️An Interface in Java programming language is defined as an abstract type used to specify the behavior of a class. An interface in Java is a blueprint of a class. A Java interface contains static constants and abstract methods.
⚜️Why do we use an Interface?✅
> It is used to achieve total abstraction.
Since java does not support multiple inheritances in the case of class, by using an interface it can achieve multiple inheritances.
> It is also used to achieve loose coupling.
> Interfaces are used to implement abstraction. So the question arises why use interfaces when we have abstract classes?
🔱 Abstraction is the property by virtue of which only the essential details are displayed to the user. The trivial or the non-essential units are not displayed to the user. Ex: A car is viewed as a car rather than its individual components
✳️An Interface in Java programming language is defined as an abstract type used to specify the behavior of a class. An interface in Java is a blueprint of a class. A Java interface contains static constants and abstract methods.
⚜️Why do we use an Interface?✅
> It is used to achieve total abstraction.
Since java does not support multiple inheritances in the case of class, by using an interface it can achieve multiple inheritances.
> It is also used to achieve loose coupling.
> Interfaces are used to implement abstraction. So the question arises why use interfaces when we have abstract classes?
👍1
Q!: Which two of the following are legal declarations for non-nested interfaces?
Anonymous Quiz
32%
public abstract class Test { }
32%
protected interface Test { }
25%
abstract public class Test{ }
12%
None
👍2
What will be the output of the following program?
public class King {
public static void main(String[] args) {
King k = new King();
Elephant e = k.new Elephant();
System.out.print("Output = ");
System.out.print(e.step2(2, 3));
}
interface Queen {
float step2(int low, int high);
}
interface Pawn {
float step3(int a, int b, int c);
}
abstract class Knight implements Queen, Pawn {
}
class Elephant implements Queen {
public float step2(int x, int y) {
return 2;
}
}
}
//
public class King {
public static void main(String[] args) {
King k = new King();
Elephant e = k.new Elephant();
System.out.print("Output = ");
System.out.print(e.step2(2, 3));
}
interface Queen {
float step2(int low, int high);
}
interface Pawn {
float step3(int a, int b, int c);
}
abstract class Knight implements Queen, Pawn {
}
class Elephant implements Queen {
public float step2(int x, int y) {
return 2;
}
}
}
//
👍2👎1🔥1
Q2:Which of the following can't be a member of an interface?
Anonymous Quiz
24%
constructors
25%
static methods
30%
non static data members
21%
All of these
👍2👎1👏1😢1
EvoNext
LESSON 14: ABSTRACTION and INTERFACES 🔱 Abstraction is the property by virtue of which only the essential details are displayed to the user. The trivial or the non-essential units are not displayed to the user. Ex: A car is viewed as a car rather than its…
LESSON 15: 📁File Class in java🗂
🔗The File class is an abstract representation of file and directory pathname. A pathname can be either absolute or relative.
📝Once you have File object in hand, then there is a list of helper methods which can be used to manipulate the files.
Eg: public String getName()
public String getParent()
public File getParentFile()
public boolean isAbsolute() ... and etc.
🔗The File class is an abstract representation of file and directory pathname. A pathname can be either absolute or relative.
📝Once you have File object in hand, then there is a list of helper methods which can be used to manipulate the files.
Eg: public String getName()
public String getParent()
public File getParentFile()
public String getPath()public boolean isAbsolute() ... and etc.
import java.io.*;
public class LearnTcode {
public static void main(String[] args) {
try {
File file = new File("learnTocode.txt");
if (file.createNewFile()) {
System.out.println("Join our channel");
} else {
System.out.println("File already exists.");
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
//output is: Join our channel❤2🥰1