Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

ITP 120 TEST #2 STUDY GUIDE Decision processing boolean expressions NOT operator

ID: 3874174 • Letter: I

Question

ITP 120 TEST #2 STUDY GUIDE Decision processing boolean expressions NOT operator (!) if statement, if...else statement, nested ifs logical operators (&& and || ) testing for multiple conditions conditional operator (? :) switch statement Looping constructs loop requirements while() loops do...while() loops for loops Nested loops Short cut operators increment/decrement operators assignment operators Use of sentinel values to control processing Scope of variables this reference and effect on overriding a variable name Class variables Symbolic constants import statement Math class Arrays – declaring allocating space for and using a subscript initializing an array arrays of objects length attribute searching an array passing to a method arraycopy() Strings – constructors comparing Strings String methods – length(), charAt(), toUpperCase(), toLowerCase(), indexOf(), concat(), replace(), substring() toString()

Explanation / Answer

Java program :

NOT OPERATOR:

SYMBOL:   !

It states that not equal operator

IF STATEMENT:

It is a decision making statement

sysntax for simple if:

if(condition)

{

-------

---------(statenments)

}

syntax for if ...else

if(condition)//condition is true executes this block otherwise moves to else

{

-------

---------(statenments)

}

else

{

-------

-------(statement)

}

NESTED IF:

if statement contains another if statement inside the block then it is said to be Nested if

syntax for nested if:

if(condition)

{

if(condition)

{

------------

-----------

}

}

LOGICAL OPERATOR:

It gives the logical operation like and,or,nor,not etcc....

it is used to compare two values shows that it is true or not

AND Symbol is &&

OR symbol is ||

MULTIPLE CONDITIONAL OPERATOR:

SYMBOL: (?:)

it checks the condition and shows the output

syntax:

condition?true:false

if the condition is true it displays values in the true otherwise displays false values

SWITCH STATEMENT:

SYNTAX:

switch(value)

{

case 0:---------------------

break;

case 1:----------------------

break;

. .

.. ....

.......

.......

}

it executes the case statement respect to the value

WHILE LOOP:

It is also a conditional loop

there are two loops

WHILE loop

DO ....WHILE loop

SYNTAX FOE WHILE:

while(condition) //it executes the block when the condition is true only

{

----

---

}

SYNTAX FOR DO WHILE LOOP:

do

{

----

---

}while(condition) //it executes the loop and checks the condition

// it is repetation loop .it repeats the block untill the condition become false

INCREMENT OPERATOR:

SYMBOL : ++

increment the value by 1

DECREMENT OPERATOR:

SYMBOL: --

decrease the value by 1

Assinment operator:

sysmbol : =

it assign the value to the variable

String methods –

length() --->find the length of the string

SYSNTAX:

string name.length();

charAt()--->find the character at string

toUpperCase()-->make the string uppercase

SYNTAX:

string name.toUppercase();

toLowerCase()--->make the string lowercase

syntax:

string name.toLowercase();

concat()--->joins two string

  

BELOW PROGRAM gives EXAMPLE of above stated some definitions:

/* package codechef; // don't place package name! */

import java.util.*;

import java.lang.*;

import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */

class Codechef

{

public static void main (String[] args) throws java.lang.Exception

{

// your code goes here

int a = 10;

int b = 20;

if(a != b)//simple if and NOT operator

{

System.out.println("not operator and if statement executed");

}

if(a == 10 && b == 20)//AND OPERATOR

{

System.out.println("AND operator executed successfully");

}

else

{

if(a == 20 || b == 10)// nested if and OR operator

{

System.out.println("OR operator executed successfully");

}

}

System.out.println(a<b?"CONDITONAL EXECUTED":"UNEXECUTED");//CONDITONAL OPERATOR

}

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote