Keyword to declare a constant variable in java which cannot be changed and the naming convention
What is final and all caps?
This term refers to an instance of a class in Java
What is an object?
Or in Java
What is two vertical lines or ||?
}
What is...
int i = 0
while i<4{
i++;
}
What is a class is a something that represents a group of objects having similar properties and behavior.
Consider the following code segment. What is the error in the code?
String sreethan = "sigma";
sreethan.concat("s");
System.out.println(sreethan);
What is strings are immutable which would cause an error for the following code segment?
An object encapsulates...
What are both attributes(fields) and behaviors (methods)?
And in Java is..
What is two ampersands or &&?
int i = 29;
while (i <= 30){
int x = i-3;
int y = x*4;
int z = 30;
System.out.println(i+x+y+z);
i--;
}
This type of loop is called a(n)....
What is an infinite loop?
Create a new class and its object.
}
x newVar = new x();
The char data type represents a _____ character.
What is unicode or single?
The keyword used to define new objects...
What is the new keyword?
kjjTwo statements that check if a boolean variable check which has been properly initialized is true using an if statement are
What is
if (boolean){
}
or
if (boolean == true){
}
This loop in Java makes sure that the block of code will run at least once, even if the condition is at first false, because the condition is checked after the loop executes.
What is a do-while loop?
This is a class member that is shared among all instances of that class, usually declared with the static keyword.
What is a static variable?
The most digits that a float in java can hold
What is 7 digits?
Create a new object for the class car(){} with the name of a car brand...
What is car mercedes = new car();?
int age = 25;
boolean hasTicket = true;
boolean isVIP = false;
if (age >= 18) {
if (hasTicket && isVIP) {
System.out.println("Welcome, VIP! You have access to the exclusive area.");
} else if (hasTicket) {
System.out.println("Welcome! Enjoy the event.");
} else {
System.out.println("Sorry, you need a ticket to enter."); }
} else {
System.out.println("Sorry, you must be at least 18 years old to enter.");
}
The output for this code segment is....
Welcome! Enjoy the event.
for (int i = 1; i <= 10; i++) {
System.out.println(i);
}
Another way to write the header for this to print values the same number of time
What is.....
for(int i = 0; i < 10; i++){
System.out.println(i);
}
?
Assume you have a project opened in Visual Studio Code with IntelliSense turned on for Java. Inside that project is a folder called VacuumSolver, and inside that folder is a file called Main.java. Main.java contains a reference to class AbstractVacuumSolver, a class contained in a file called VacuumSolverEssentials.java in a folder called Libs in the VacuumSolver folder. Assuming that this reference has not been correctly imported, use standard Java import syntax to import this class in Main.java. Assume the package keyword has been correctly used above every java source file in the project.
import VacuumSolver.Libs.AbstractVacuumSolver;
int test1 = 95;
int test2 = 100;
int test3= 98;
double avg = (double)test1+test2+test3/(double)3
The right way to write the last line is...
What is double avg = (double) test1+test2+test3/3?
public static class main
{
System.out.println("OOPs");
}
Create an object for this static class
What is that is not possible?
String number = "1234";
String letters = "abcd";
int numbers = 1234;
int letter = 1234;
if number == letters{
if numbers == letter{
number += "5678";
}else{
letter += "efgh";
}
}else{
System.out.println("You are Wrong");
}
The result of this code segment...
What is code will print "You are Wrong"?
for (int i = 1; i <= 10; i++) {
System.out.print(3 * i + " ");
}
int count = 0;
int num = 1;
while (num <= 50) {
if (num % 4 == 0) {
count++;
}
num++;
}
System.out.println("\nNumbers divisible by 4 from 1 to 50: " + count);
The output is
What is ...
3 6 9 12 15 18 21 24 27 30
Numbers divisible by 4 from 1 to 50: 12 ?
public void number(){
int number = 1234;
return number;
}
This code is wrong because..
What is you can't return in void classes only have actions like printing or other behaviors/attributes other than return?