Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Document preview thumbnail
Preview 4 out of 72 pages
Exam (elaborations)

CSE 1322 LAB AND LECTURE EXAM 3 COMPLETE PREPARATION GUIDE WITH DATA STRUCTURES AND ALGORITHMS BASICS

Document preview thumbnail
Preview 4 out of 72 pages

CSE 1322 LAB AND LECTURE EXAM 3 COMPLETE PREPARATION GUIDE WITH DATA STRUCTURES AND ALGORITHMS BASICS

Content preview

CSE 1322 LAB AND LECTURE EXAM 3
COMPLETE PREPARATION GUIDE WITH DATA
STRUCTURES AND ALGORITHMS BASICS

◉ Java
class Numbers {
public int a;
public static int b;
public Numbers(int c) {
a+=c; b+=c; }
public int get_b() {
return b; }}
class Main {
public static void main(String[] args) {
Numbers n1=new Numbers(2);
Numbers n2=new Numbers(3);
System.out.println("a: "+n2.a+" b: "+Numbers.b);}}.
Answer: a: 3 b: 5


◉ int x=10;for(int i=5;i<0;i--) {x++;}System.out.println(x);.
Answer: 10

,◉ What is the output of the following statements:
//Java:
String s="Hi";
for(int i=0;i<3;i++) {
System.out.print("S"+s);
}.
Answer: SHiSHiSHi


◉ Which of the following are valid variable declarations:
(Select ALL that are valid).
Answer: int a=1102;
long b=1;
Java:
String d="";
C#:
string d="";


◉ Which of the following blocks of code will successfully ask a user
for a number, multiply that number by 2, and print the result.
Answer: Java
import java.util.Scanner;

,System.out.println("Enter a number to be doubled:");
Scanner myscanner = new Scanner(System.in);
int num=myscanner.nextInt();
num*=2;
System.out.println("Your number doubled is "+num);


◉ Java
boolean a=false;
boolean b=true;boolean c=false;boolean d=true;
if((a) && (b || c) && d) {
System.out.println("Yes");
}else {
System.out.println("No");}.
Answer: No


◉ The following code will not compile as is. It is missing a line that
needs to be inserted where the "//Missing Line" comment is. Which
line of code will fix the compile error?


class House {
public int square_footage;
public int stories;

, public House() {
square_footage=0;stories=1;}}
class Main {public static void main(String[] args) {
House h1;
//Missing Line
h1.square_footage=1;}}.
Answer: h1 = new House();


◉ class Stuff {
public int number=1;
}
class Main {
public static void do_things(int y) {
y+=3;
}
public static void do_other_things(Stuff y) {
y.number+=3;
}
public static void main(String[] args) {
int a=3;
Stuff myStuff = new Stuff();
do_things(a);

Document information

Uploaded on
August 25, 2026
Number of pages
72
Written in
2026/2027
Type
Exam (elaborations)
Contains
Questions & answers
$14.99

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
TopGradeInsider
4.2
(13)
Sold
165
Followers
2
Items
55375
Last sold
11 hours ago



Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions