This document outlines approaches to everything required for the IEB IT Java Practical Examination. These notes were developed by a candidate in the Top 1% in the IEB for Information Technology in 2020.
Typecasting
String → int
int num = Integer.parseInt (Str);
String → double
double num = Double.parseDouble (Str);
double → int
int intNum = (int) dblNum;
int → double
double dblNum = intNum;
int → char (Converts to ASCII Value)
char ch = (char) intNum;
char → int (Converts to ASCII Number)
int intNum = (int) ch;
int → String
String str = “ ” + intNum;
double → String
String str = “ ” + dblNum;
String → char
char ch = str.charAt(index);
.toUpperCase() or .toLowerCase()
char → String
String str = “ ” + ch;
Formatting and Arithmetic
Constants / Finals:
public/private static final <type> <name> = <value>;
Useful Tools:
String.format("%.2f", <double>); round off to 2 decimals
System.arraycopy (<sourceArr>, <sourcePos>, <destArr>, <destPos>, <size>); copy
part of an array into another array
Math Class:
Square Root: Math.sqrt (x)
Raise to Power: Math.pow (x, exponent)
Round off: Math.round (x)
Absolute Value: Math.abs (-x)
Random Number: Math.random () * (max) + (start)
Array Handling
Declaring an array:
[variable type] [variable name] [] = new [variable type] [size];
Inputting an array with a known amount of values:
int array [] = new int [10];
for (int loop = 0; loop < 10; loop++){
array [loop] = [input method];
}//end for loop
Inputting an array with an unknown amount of values:
int count = 0;
String wrdArr [] = new String [10]
wrdArr [count] = [input method];
while (!wrdArr [count].equalsIgnoreCase (“stop”)){
count++;
wrdArr [count] = [input method]
}//end while loop
Displaying an array:
for (int loop = 0; loop < [size]; loop++){
System.out.println (array [loop]);
}//end for loop
Inserting into an array:
public void shiftRight (int insertPos, String newString){
for (int loop = size; loop > insertPos; loop--){
stArr [loop + 1] = stArr [loop];
}//end for loop
stArr [insertPos] = newString;
size++;
}//shiftRight insert method
Deleting from an array
public void shiftLeft (int removePos){
for (int loop = removePos; loop < size; loop++){
stArr [loop] = stArr [loop + 1];
}//end for loop
size--;
}//shiftLeft delete method
Or you can just override the deleted array index with the last index and call a
sort method.
Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.
Quick and easy check-out
You can quickly pay through EFT, credit card or Stuvia-credit for the summaries. There is no membership needed.
Focus on what matters
Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!
Frequently asked questions
What do I get when I buy this document?
You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.
Satisfaction guarantee: how does it work?
Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.
Who am I buying this summary from?
Stuvia is a marketplace, so you are not buying this document from us, but from seller NikharRamlakhan. Stuvia facilitates payment to the seller.
Will I be stuck with a subscription?
No, you only buy this summary for R150,00. You're not tied to anything after your purchase.