Java Exam 1 Study Guide Question 1 Explain the importance of each topic in Java
ID: 673582 • Letter: J
Question
Java Exam 1 Study Guide
Question 1
Explain the importance of each topic in Java and provide a example/ how-to for each.
1. Strings and string formatting
2. Errors and error messages
3. Variables and types
4. Expressions, operators: %, /, *, +, -
5. Boolean operators, expressions and values: true or false, &&, ||, !
6. DeMorgan's Laws: (a&&b)=(!a)||(!b) (a||B)=(!a)&&(!b)
7. Conditions (f, ifelse)
8. Loops ( for loop, while loops, break, continue)
~
I know this is not your typical question but I have been having a hard time understanding and learning Java in my intro t programming course at Uni. The first exam in our couse is tomorrow and i am not really sure how i should study but these are the topics that the test will cover. Any help is greatly appreciated, thank you .
Explanation / Answer
1.String and String formatting:-
basic syntax String t="Hello World"; When we write this t is created as String class object but t is not a literal.
you can access the characters of t as t.charAt(0) is 'H'.And Length is t.length();The String class is immutable, so that once it is created a String object cannot be changed.
Strings can be concated just by using '+'; or by concat
String.format() is used to format the output of the String object;Other formatting classes are alo present;
Errors
General common errors can be seen in IDE that is syntax erros and some logical erros of implementing classes and objects.
But at the runtime exceptions are arised and handled by exceptional class.Like divisionbyzero ,Inputmismatch like that.We can also define the exceptions by user.
Variables and types: common variable like int ,bool,double,char and long unsigned all are present.like any other variables.
Expressions, operators: %, /, *, +, -
% is modulo 5%2=2
/ divide
* multiplication
+ addition
- subtraction
Boolean operators, expressions and values: true or false, &&, ||, !
bool f=false then f is false && is and ! is not(negation) || is or
DeMorgan's Laws: (a&&b)=(!a)||(!b) (a||B)=(!a)&&(!b) if put in a if() then it is false
Conditions:- if else
if(condition){ //if condition is true if block will be executed other wise else will be executed
}else{
}
switch(){
cases
default
}
. Loops ( for loop, while loops, break, continue)
for(int i=0;i<10;i++){
//loop runs for 10 times
}
while(condtion){
}
do{
}while(condition)
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.