This document provides guidance on several Java programming concepts for an exam. It notes to show step-by-step work, consider semicolons properly, and check for print versus println. Fundamental concepts covered include data type promotions and conversions, operator precedence, and formatting floating point numbers. Selections discusses logical operators and switch only applying to integral values. Repetitions reviews loop declarations and variable scope. Methods emphasizes overloading, parameters, and static methods. Arrays notes the zero-based index, enhanced for loops, and binary search. Static differentiates static and non-static contexts. Classes and interfaces cover constructors, access modifiers, final variables, and inheritance rules.
This document provides guidance on several Java programming concepts for an exam. It notes to show step-by-step work, consider semicolons properly, and check for print versus println. Fundamental concepts covered include data type promotions and conversions, operator precedence, and formatting floating point numbers. Selections discusses logical operators and switch only applying to integral values. Repetitions reviews loop declarations and variable scope. Methods emphasizes overloading, parameters, and static methods. Arrays notes the zero-based index, enhanced for loops, and binary search. Static differentiates static and non-static contexts. Classes and interfaces cover constructors, access modifiers, final variables, and inheritance rules.
This document provides guidance on several Java programming concepts for an exam. It notes to show step-by-step work, consider semicolons properly, and check for print versus println. Fundamental concepts covered include data type promotions and conversions, operator precedence, and formatting floating point numbers. Selections discusses logical operators and switch only applying to integral values. Repetitions reviews loop declarations and variable scope. Methods emphasizes overloading, parameters, and static methods. Arrays notes the zero-based index, enhanced for loops, and binary search. Static differentiates static and non-static contexts. Classes and interfaces cover constructors, access modifiers, final variables, and inheritance rules.
○ Consider the semi colon ‘;’ after the if condition or after for loop ○ notice Println or print ○ Valid promotions for primitive data types ○ Global variables cant be called from main unless its static ○ Whenever the questions mentioned the package it will ask about access modifiers (private, package access, modifier) ○ Read the whole question starting from the import statements ● Fundmentals: ○ Int can assigned with char but char cant assigned with int ○ Float with no ‘f’ is double, and without . is int ○ Mathematical operations precedence ■ ++, -- , *, / , % +, -, ○ Scanner declaration and input errors ○ Formatting the floating number ○ Casting operations can be done automatically when it casting from lower to higher level in data types but it should be explicitly written if its from higher to lower level ● Selections ○ Not connected else F2 P7 ○ Boolean logical | and & ○ Switch perform only on integral numbers and char ● Repetitions ○ Loops declarations ○ For loop declaration scope ○ Notice the body for the loop or only the first line will be executed ● Methods ○ Focus on methods overloading, passing parameters(order and type) ○ Static function used only in static context( scope ) ○ Valid promotions for primitave data types ○ Notice the scope of the variables. ● Arrays ○ Arrays is ZEROED indexed which means its starts in 0 index ○ Always solve step by step using your pencil ○ Enhanced for statement ○ Variables arguments array ○ Binary search if its exist it will return the index, if not it will return size of sorted index with lower values only and added one by negative. ● Static ○ Static methods call only static methods ○ Cant use ( this ) in static context ○ Static methods use only static variables ● Classes ○ Calling constructor only from another constructor ○ Calling constructor only the first line in the constructor ○ Final variables sould be initialized directly or in all the constructors ○ Always check for access modifier and static modifier for every access line ○ Cant call the same constructor recursively. ○ Super class must be called if we dont have default constructor ● Interface ○ All fields are implicitly public, static, final ○ All methods are implicitly public, abstract