قناة هندسة الحاسب
836 subscribers
2.29K photos
38 videos
969 files
321 links
1. القناة مخصصة للدراسة ولمقررات القسم وأخباره، يمنع نشر غير ما يتعلق بهذا إلا في حالات استثنائية.

2. يجب استعمال الهاشتاقات لكل مقرر يراد نشر شيء يخصه، وهاشتاق #إعلان للإعلانات.
Download Telegram
#EC252

[Lecture 4]

•the method's header consists of:
-modifiers (public, static, etc)
-return value type (int, string, void, etc)
-method's name
-parameter list (formal parameters)

• a method's "signature" is its name and formal parameters

• when invoking a method, the variables passed to it are called "actual parameters" or "arguments"

• in some programming languages:
a value-returning method is called a function
a void method is called a procedure

• we say "define a method" but "declare a variable" because declaration usually involves allocating memory to store data for the declared item

• the only way to give information to a method is through parameters

• call by value: when a variable is passed to a method through its parameters, the method uses a copy of the variable not the original variable. because the parameters in methods are different variables than the variables introduced in the method call. primitive data types follow this rule (int, double, float, char, boolean, short, long, byte).

• call by reference: ArrayLists as parameters are an exception to the rule mentioned above because they are reference data types. when a method is passed an ArrayList as a parameter, it gains access to the original Arraylist, and any changes made by the method will be made to the original Arraylist.

• an object contains a related group of "information" (values) and "functionality" (methods).

• objects are instances of classes.
• the type of a certain group of objects is called a class.
• a class defines what method its objects have and attributes.
13👏2💯2
#EC252
تعريف وفائدة الـ signature.

In Java, a signature refers to the unique identifier of a method or constructor. It consists of the method's name and the types of its parameters in the order in which they appear. The return type of the method is not part of its signature.

For example, consider the following method:


public int add(int a, int b) {
    return a + b;
}


The signature of this method is "add(int, int)".

Java uses method signatures to determine which method to call when there are multiple methods with the same name in a class. This is known as method overloading. If two methods have the same name but different signatures, Java can determine which method to call based on the arguments passed to it.
8
https://youtube.com/playlist?list=PL59LTecnGM1MMSBPiLN4aMwM7DcnVld0s


playlist فيها برامج تقدروا تدربوا عليها
#EC252
2👍1
#EC252
[Lecture 5]

the toString() method and how it's used

https://www.javatpoint.com/understanding-toString()-method
#EC252
ملخص سلايد الدكتور
[Lecture 5]

• an object is always created from its class by calling the method (the constructor) that creates the object with the command new

• a class has to define what methods and attributes the objects created from the class will have

• defining attributes within an object is done in quite a familiar fashion as normal variable

• writing the keyword private before attributes makes them hidden within the object and not show outside of it

• hiding things within an object is called encapsulation

• variables defined within a class are called object variables, object fields or object attributes.

• the 'state' of the object is determined by the values that have been set to its variables

• self-defined objects are created in the same way as ready-made objects, with the new command

•  a constructor is a method used to instantiate and initialize objects
•  it must have the same name as the class
•  does not have a return type
•  is invoked using the new operator

• if you don't create a constructor for your class, java will automatically create a default constructor
• a default constructor is a zero-argument constructor (takes no parameters), with an empty body, and can only be used to create objects from the class

• toString() : is a method that returns a string representation
• the System.out.println method requests the string representation of an object and then prints it, so..

System.out.println( objectName );
// same output as
System.out.println( objectName.toString );

• the "this" keyword
is a refrence to the object itself (another name for the object)
It's used before the dot operator "." to:
- reference instance data fields
- reference instance methods
- invoke a constructor

• String.format("%.2f, value);
returns a string where the value is rounded to contain 2 decimals

• when calling an object's method within the object, you can ditch the "this" keyword


• Random: is a ready-made class in java you can use to create objects that has the following methods:

.nextInt();
can be given an integer value as a parameter
returns a random integer within the range [0, parameter-1]

.nextDouble();
doesn't accept any parameters
returns the next pseudorandom, "uniformly" distributed double value between 0.0 and 1.0 from this random number generator's sequence

.nextGaussian();
doesn't accept any parameters
returns the next pseudorandom, Gaussian "normally" distributed double value with mean 0.0 and standard deviation 1.0 from this random number generator's sequence
8
#Ec201
محاضرة اليوم.
ملاحظة 💡
لاتوجد توتوريـَال
Java naming conventions:
Class names: Capitalize the first letter in each name (Pascal).

Variables and method names: Lowercase the first word, capitalize the first letter in all subsequent words (camelCase).

Constants: Capitalize all letters.
#EC252
4
مرة مرة بنبعت اسئلة mcq
#EC252
1