EvoNext
1.79K subscribers
272 photos
16 videos
266 files
484 links
Download Telegram
EvoNext pinned «LESSON 5: JAVA MATH: ⚜️The Java Math class has many methods that allows you to perform mathematical tasks on numbers. ✳️The Math.sqrt(x) method returns the square root of x. ✳️The Math.max(x,y) method can be used to find the highest value of x and y.…»
which method of Math Class of package java.util is not used for rounding a numbers to the nearest integer:
Anonymous Poll
16%
Math.round();
16%
Math.floor();
16%
Math.ceil();
52%
Math.random();
19%
NONE
👍31
midterm_solutions.pdf
49.4 KB
😉questions with solution for java.
join >M-coders
share >for OTHER"S
DISCUSSION GROUP» https://t.me/learntocodecpp
👍3
EvoNext
LESSON 5: JAVA MATH: ⚜️The Java Math class has many methods that allows you to perform mathematical tasks on numbers. ✳️The Math.sqrt(x) method returns the square root of x. ✳️The Math.max(x,y) method can be used to find the highest value of x and y.…
LESSON 6: ARRAY AND 2D ARRAYS

An array is a collection of items stored at contiguous memory locations. The idea is to store multiple items of the same type together.
✳️Multidimensional Arrays can be defined in simple words as array of arrays. Data in multidimensional arrays are stored in tabular form (in row major order).
*In the array there will be:
data_type : type of data to be stored in the array
dimension: the dimension of the array is created. like 1D, 2D ...
array_name: name of the array
finally , the size of the array.
#example_of_array:;
class CODER
{
public static void main (String[] args)
{
// declares an Array of integers.
int[] arr;

// allocating memory for 5 integers.
arr = new int[5];

// initialize the first elements of the array
arr[0] = 10;

// initialize the second elements of the array
arr[1] = 20;

//so on...
arr[2] = 30;
arr[3] = 40;
arr[4] = 50;

// accessing the elements of the specified array
for (int i = 0; i < arr.length; i++)
System.out.println("Element at index " + i +
" : "+ arr[i]);
}
}


2D array:-

class Learn {
public static void main(String[] args)
{

int[][] arr = new int[10][20];
arr[0][0] = 1;

System.out.println("arr[0][0] = " + arr[0][0]);
}
}
Q; What is the output of the following code fragment?
int [ ] odd = {1, 3, 5, 7, 9, 11 };
System.out.println( odd[0] + " " + odd[3] ) ;
Anonymous Poll
15%
[a] 1 5
14%
[b] 6
63%
[c] 1 7
22%
[d] 8
👍1
Q; Which code line could possibly "call" this method?
public static int SomeMethod(double[ ] array, int[ ] number)
{ . . . }
Anonymous Quiz
25%
[a] int value = SomeMethod(money, grades);
38%
[b] SomeMethod(money, grades);
29%
[c] double value = SomeMethod(money, grades);
8%
[d] int value = SomeMethod(money);
👍1
EvoNext
LESSON 6: ARRAY AND 2D ARRAYS An array is a collection of items stored at contiguous memory locations. The idea is to store multiple items of the same type together. ✳️Multidimensional Arrays can be defined in simple words as array of arrays. Data…
LESSON 7:
LOOPS AND NESTED LOOPS
✳️Looping in java helps by facilitating the execution of of a set of instructions repeatedly while some condition evaluates to true.

1. While-loops: allows the code to be executed repeatedly based on a given Boolean condition.
   while (boolean condition)
{
loop statements...
}
2. for-loops: unlike while statement, it consumes the initialization, condition, and increment/decrement.
for (initialization condition; testing condition;
increment/decrement)
{
statement(s)
}

3. do-while: do while loop is similar to while loop with only difference that it checks for condition after executing the statements.
do
{
statements..
}
while (condition);

sample example for for-loop:


public class Loops
{
public static void main(String[] args)
{
ArrayList<Integer> ar = new ArrayList<>();//we will see about list in the next lessons
for (int i = 0; i < Integer.MAX_VALUE; i++)
{
ar.add(i);
}
}
}


link to get our Channel» https://t.me/PROGRAMINGLANGUAGES1»
group for your comments» https://t.me/learntocodecpp
👍1
👍1
Q. What will be displayed when the following code is executed? int x = 0;
int number = 6;
while (number > 0) { number -= 3; System.out.print(number + " "); }
Anonymous Quiz
12%
0
34%
6,3
42%
3,0
11%
6,3,0
👍1👏1
LearnToCode|javaWS.pdf
487 KB
file: 487 kb pdf #only
#different looping structures in java👌🏻
👍1
EvoNext pinned «👥 GROUP FOR PROGRAMMERS -> JOIN»
basics of java (2).pdf
1.5 MB
Short notes for Java.

@more lessons for java @Learn_to_Code
👍4
EvoNext
LESSON 7: LOOPS AND NESTED LOOPS ✳️Looping in java helps by facilitating the execution of of a set of instructions repeatedly while some condition evaluates to true. 1. While-loops: allows the code to be executed repeatedly based on…
LESSON 8: WRAPPER CLASSES IN JAVA



Wrapper classes provide a way to use primitive data types (int, boolean, etc..) as objects.

✳️Sometimes you must use wrapper classes, for example when working with Collection objects, such as ArrayList, where primitive types cannot be used (the list can only store objects):

example:
ArrayList<Integer> myNumbers = new ArrayList<Integer>(); // Valid

Creating Wrapper Objects

To create a wrapper object, use the wrapper class instead of the primitive type. To get the value, you can just print the object:
Example

public class Main {
public static void main(String[] args) {
Integer myInt = 5;
Double myDouble = 5.99;
Character myChar = 'A';
System.out.println(myInt);
System.out.println(myDouble);
System.out.println(myChar);
}
}

//

Share for programmer friends!>
https://t.me/PROGRAMINGLANGUAGES1
👍1
The following code will not compile or run. WHY?
👍1
EvoNext
LESSON 8: WRAPPER CLASSES IN JAVA Wrapper classes provide a way to use primitive data types (int, boolean, etc..) as objects. ✳️Sometimes you must use wrapper classes, for example when working with Collection objects, such as ArrayList, where primitive…
LESSON 9: CONSTRUCTORS in Java

✳️ A constructor in Java is a special method that is used to initialize objects. The constructor is called when an object of a class is created. It can be used to set initial values for object attributes.


How Constructors are Different From Methods in Java?

❤️ Constructors must have the same name as the class within which it is defined while it is not necessary for the method in Java.
❤️Constructors do not return any type while method(s) have the return type or void if does not return any value.

❤️Constructors are called only once at the time of Object creation while method(s) can be called any number of times.

Example: look the sample code having two constructors;

package ubJapro1;
//import java.util.*;


public class Firsta {

public static void main(String[] args) {

Firsta2 firs = new Firsta2("ashe",34,76.4);// constructor 1
Firsta2 firs2 = new Firsta2("asegid",32,70.4);// constructor 2

System.out.println(firs.name+" is your name.");

firs2.home();

}





}


» share for your programmer friends:
https://t.me/PROGRAMINGLANGUAGES1
EvoNext
LESSON 9: CONSTRUCTORS in Java ✳️ A constructor in Java is a special method that is used to initialize objects. The constructor is called when an object of a class is created. It can be used to set initial values for object attributes. How Constructors…
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 means the methods of an object.
⚜️Identity means the unique name to an object.


the four ways of creating objects in java

1. using new key word

//Test t = new Test();
2. Using Class.forName( String className) method;

  Test obj = (Test)Class.forName("com.p1.Test").newInstance();

3. using clone() method

/Test t = new Test();
Test t2 = (Test)t1.clone();

4. Deserialization
it is is technique of reading an object from the saved state in a file.

example using the first way:

 class Animal {}

class Dog extends Animal {}
class Cat extends Animal {}

public class Test
{
// using Dog object
Animal obj = new Dog();

// using Cat object
obj = new Cat();
}


SUPPORT US BY JOINING AND SHARING;
https://t.me/PROGRAMINGLANGUAGES1: thanks
👍4