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
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:
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
https://t.me/PROGRAMINGLANGUAGES1
β 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>(); // ValidCreating 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
Q1: Which of the following is the correct syntax for writing a methode with parameters?
Anonymous Quiz
13%
public static void example(x:int, y:int) {...}
16%
public static void example(x , y) {...}
60%
public static void example( int x , int y) {...}
11%
public static void example( int x, y) { ...}
π1
Q2:Which of the following is true about Javaβs enhanced for statement? Choose one.
Anonymous Quiz
28%
the loop can iterate directly over java.util.*;
30%
the loop does not provide access to the index of the current element
16%
the loop supports deletion of the current element during execution of the loop
26%
Early termination of the loop via a break statement is prohibited.
π₯°1
EvoNext
The following code will not compile or run. WHY?
Q3: Choose the correct Answer: for the above correct question
Anonymous Quiz
10%
Missing curly brackets
15%
Constructors have wrong name( s)
73%
Can not create two identical constructors
3%
Pay rate should be float
π5
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 isa 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;
share for your programmer friends:
https://t.me/PROGRAMINGLANGUAGES1
β³οΈ A constructor in Java is
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();
}
}
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
//
/
it is is technique of reading an object from the saved state in a file.
β example using the first way:
https://t.me/PROGRAMINGLANGUAGES1: thanks
β³οΈ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. Deserializationit 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
Q10: which one is not true about instance variable?
Anonymous Quiz
28%
there is exactly one copy of the this variable in extistnce
25%
their value is unique to each instance class
23%
they should not be declared with the static key word
14%
they have no default value before the first use
9%
NONE
π4
1.Object o = new Object(); 2. Object obj = o; Β»>In the cases given above, identify their difference?
Anonymous Quiz
16%
"o" and "obj" are Objects
39%
"o" is an Object, but "obj" is object variable.
31%
both "o" and "obj" are object variables
14%
NONE
π4π₯1
LEARNtoCODE@javaQuestionsP1.pdf
47.3 KB
Description: Theory_part practice for java
file size: 47.3 kb only
Prepared by: Learn to code();
πJava lessons continue on our channel..
Join and share : https://t.me/PROGRAMINGLANGUAGES1
file size: 47.3 kb only
Prepared by: Learn to code();
πJava lessons continue on our channel..
Join and share : https://t.me/PROGRAMINGLANGUAGES1
π1
ππGREAT OFFERπππ
ARE YOU FRESHMAN STUDENTβοΈ
Are you looking for freshman reading materials?
then look at this gift for π―% free:
- modules
- exams[ mid, final] of different universities
- reference books
- and different materials in voice and videos
.... are some of them.
first semister courses:-
β General physics
β mathematics for natural
β mathematics for social
β logic and critical thinking
β communicative english
β Psychology
β Geography
second semister courses:
β Emerging
β general biology
β applied mathematics
β programming I
β civcs and moral education
β economics
β anthropology
β communicative english II
....much more!
https://t.me/exbost
https://t.me/exbost
https://t.me/exbost
join learn to code
https://t.me/exbost
SHARE FOR YOUR FRIENDS!γ½οΈ
ARE YOU FRESHMAN STUDENTβοΈ
Are you looking for freshman reading materials?
then look at this gift for π―% free:
- modules
- exams[ mid, final] of different universities
- reference books
- and different materials in voice and videos
.... are some of them.
first semister courses:-
β General physics
β mathematics for natural
β mathematics for social
β logic and critical thinking
β communicative english
β Psychology
β Geography
second semister courses:
β Emerging
β general biology
β applied mathematics
β programming I
β civcs and moral education
β economics
β anthropology
β communicative english II
....much more!
https://t.me/exbost
https://t.me/exbost
share for your friendhttps://t.me/exbost
https://t.me/exbost
join learn to code
https://t.me/exbost
SHARE FOR YOUR FRIENDS!γ½οΈ
β€2π1