0% found this document useful (0 votes)
5 views2 pages

Java Programming Assignment Solutions

Uploaded by

alexnazary
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views2 pages

Java Programming Assignment Solutions

Uploaded by

alexnazary
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

SQA 210 – Java Assignment 01

Q1 - What will be the output of the below programs?


public class IncrementDecrementQuiz
{
public static void main(String[] args)
{
int i=1, j=2, k=3;

int m = i-- - j-- - k--;

[Link]("i="+i);
[Link]("j="+j);
[Link]("k="+k);
[Link]("m="+m);
}
}

public class IncrementDecrementQuiz


{
public static void main(String[] args)
{
int a=1, b=2;

[Link](--b - ++a + ++b - --a);


}
}

public class IncrementDecrementQuiz


{
public static void main(String[] args)
{
int x = 001, y=010, z=100;

int i = --x + y++ - z-- - --z + ++y - --x + y-- - --x;

[Link]("x="+x);
[Link]("y="+y);
[Link]("z="+z);
[Link]("i="+i);
}
}

[Link]
Q2 – You are given the following Strings, reverse the string if the length of it is odd, if not then remove one character from the end of it and then reverse it.
1- “Book”
2- “Testing”
3- “I am going to get a job”
4- “Learning”
5- “My code works”

Q3 – Create arrays based on the following requirements and then using for loop, go through each and print all variables in each:
1- Array of strings that holds the values “blue”, “red”, “brown”, “white”, and “yellow”

2- Array of integers that holds the values 15,18,26,24,25,8,5,411,26,2,1

Q4 – Create arrays that matches the following requirements and then write code that finds the solution requested for each:
1- Array of integer that holds values 15,5,13,5,1,4,2,5,36,3,4,2
Logic: after creating the array, write a loop that goes through the array and try to find the largest number in the array using that loop and any other
element that you may need.

2- Array of chars that holds the values c,s,c,s,r,g,a,c,d,g


Logic: after you have the array with all the chars in it, write a for loop that goes through the array and checks to see if each char is same as the previous
char in the array. As soon as you find the first instance that there are two of the same char in a sequence, you can break the loop and print found it + the
char value.

Q5 – Explain the following procedures and terms: (add as much detail as you can)
- assignment,
- calling a variable,
- initialization,
- declaration,
- for loop structure
- if, else, else if
- conditional operators

[Link]

You might also like