Can you take a second to vote the poll to easy our notes and meets you well, which grade are you categorized in?
Anonymous Poll
8%
High school student
32%
Freshman student
63%
Bsc student
5%
Others
EvoNext
💻LESSON2🔖✍️ #Compiling a Program Compiling converts the source files that you write into bytecode that can be executed by a Java Virtual Machine. The source file has a #.java extension. It also defines a public class of the same name. For example, the class…
LESSON 3
ASSIGNMENT
✅> Every variables is assigned data type that designates the type and quantity of value it can hold.
✳️<> as many of you guess , variable is a name given to a memory location.
⚜️During declaration of a variable, we nedd to take care of two things
1. Dataype
2. Dataname
Similarly , we can initialize variables by assigning values in two ways:
1.variable initialization//
2. Assigning value by taking input from user//
/look the snippet code below with different dataypes and initializations
ASSIGNMENT
✅> Every variables is assigned data type that designates the type and quantity of value it can hold.
✳️<> as many of you guess , variable is a name given to a memory location.
⚜️During declaration of a variable, we nedd to take care of two things
1. Dataype
2. Dataname
Similarly , we can initialize variables by assigning values in two ways:
1.variable initialization//
2. Assigning value by taking input from user//
/look the snippet code below with different dataypes and initializations
public class Firsta {
public static void main(String[] args) {
long x = 2345267;
float y =3.45f;
boolean z = true;
char ch = '@';
String str ="learn to code!!";
System.out.println("the number is: " +x);
System.out.println(y);
System.out.println(z);
System.out.println(ch);
System.out.println(str);#Q1, From the statements given below, select the choice which assigns a value to X ?
Anonymous Poll
23%
X ++;
28%
Y = X;
26%
X == Y;
27%
None
👍5
EvoNext
LESSON 3 ASSIGNMENT ✅> Every variables is assigned data type that designates the type and quantity of value it can hold. ✳️<> as many of you guess , variable is a name given to a memory location. ⚜️During declaration of a variable, we nedd to take…
LESSON 4:
IMPORTING SCANNER CLASS IN | JAVA
👨🏽💻Scanner is a class in java.util package used for obtaining the input of the primitive types like int, double, etc. and strings.
✳️To read numerical values of a certain data type XYZ, the function to use is nextXYZ().
✅ To read strings, we use nextLine().
🔱To read a single character, we use next().charAt(0). next() function returns the next token/word in the input as a string and charAt(0) function returns the first character in that string.
» GROUP To cONTRIBUTE YOUR SKILL
IMPORTING SCANNER CLASS IN | JAVA
👨🏽💻Scanner is a class in java.util package used for obtaining the input of the primitive types like int, double, etc. and strings.
✳️To read numerical values of a certain data type XYZ, the function to use is nextXYZ().
✅ To read strings, we use nextLine().
🔱To read a single character, we use next().charAt(0). next() function returns the next token/word in the input as a string and charAt(0) function returns the first character in that string.
import java.util.Scanner;
public class Firsta {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println("enter some String");
String name = scanner.nextLine();
System.out.println("enter your age");
int x = scanner.nextInt();
scanner.nextLine();
System.out.println("what is you departent? ");
String dep =scanner.nextLine();
System.out.println("your name is: "+name);
System.out.println("your age is:"+ x);
System.out.println("your in "+dep+" departement now!");
}
}
» share and join this channel and» GROUP To cONTRIBUTE YOUR SKILL
👍2
Q2: Which is the correct syntax to declare scanner class object?
Anonymous Poll
13%
Scanner objectName = Scanner():
23%
Scanner objectName =new Scanner():
13%
Scanner objectName = Scanner(System.in):
58%
Scanner objectName =new Scanner(System.in):
13%
NONE
OOP worksheet.pdf
30 KB
WORKSHEET FOR JAVA |LEARN TO CODE
https://t.me/PROGRAMINGLANGUAGES1
SHARE FOR MORE PROGRAMMING MATERIALS : thanks
https://t.me/PROGRAMINGLANGUAGES1
SHARE FOR MORE PROGRAMMING MATERIALS : thanks
EvoNext
LESSON 4: IMPORTING SCANNER CLASS IN | JAVA 👨🏽💻Scanner is a class in java.util package used for obtaining the input of the primitive types like int, double, etc. and strings. ✳️To read numerical values of a certain data type XYZ, the function to…
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.
✳️ The Math.abs(x) method returns the absolute (positive) value of x.
❤️ Math.random() returns a random number between 0.0 (inclusive), and 1.0 (exclusive).
https://t.me/PROGRAMINGLANGUAGES1»
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.
✳️ The Math.abs(x) method returns the absolute (positive) value of x.
❤️ Math.random() returns a random number between 0.0 (inclusive), and 1.0 (exclusive).
public class Firsta {
public static void main(String[] args) {
double x,y,z;
/*double x = 3.14;
double y = 3.41;
double z = Math.max(x, y);
double a = Math.sqrt(5);
double ab = Math.ceil(x);// maximum number
double ac = Math.floor(y);// minimum number
System.out.println(z);*/
System.out.println(a);
System.out.println(ab);
‼️THERE ARE ALOT OF METHODS IN JAVA FOR FURTHER MATHEMATICAL OPERATIONShttps://t.me/PROGRAMINGLANGUAGES1»
👍1
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
👍3❤1
midterm_solutions.pdf
49.4 KB
😉questions with solution for java.
join >M-coders
share >for OTHER"S
DISCUSSION GROUP» https://t.me/learntocodecpp
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:;
✅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] ) ;
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)
{ . . . }
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
Q; Which code line could possibly "call" this method?
public static int SomeMethod(double[ ] array, int[ ] number)
{ . . . }
public static int SomeMethod(double[ ] array, int[ ] number)
{ . . . }
‼️: ignore [a], [b],[c] and [d] it is only to identify the choice
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.
3. do-while: do while loop is similar to while loop with only difference that it checks for condition after executing the statements.
link to get our Channel» https://t.me/PROGRAMINGLANGUAGES1»
group for your comments» https://t.me/learntocodecpp
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)2. for-loops: unlike while statement, it consumes the initialization, condition, and increment/decrement.
{
loop statements...
}
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
Q; What is the output of the following code?
Anonymous Quiz
5%
int x = 0; while (x < 4) { x = x + 1; } System.out.println("x is " + (++x));
6%
8
6%
9
33%
5
23%
4
27%
None
👍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 + " "); }
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