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

Java Differences Tables

The document outlines key differences between various programming concepts, including char vs String, assignment vs comparison operators, and primitive vs non-primitive data types. It also compares mathematical functions like Math.pow() vs Math.sqrt() and Math.rint() vs Math.round(), as well as the distinctions between prefix vs postfix increments and types of errors in programming. Additionally, it explains entry control loops versus exit control loops.
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)
7 views2 pages

Java Differences Tables

The document outlines key differences between various programming concepts, including char vs String, assignment vs comparison operators, and primitive vs non-primitive data types. It also compares mathematical functions like Math.pow() vs Math.sqrt() and Math.rint() vs Math.round(), as well as the distinctions between prefix vs postfix increments and types of errors in programming. Additionally, it explains entry control loops versus exit control loops.
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

Differences (Tabular Form)

1. Difference between char and String


char String
Stores a single character Stores multiple characters (sequence)
Written in single quotes (' ') Written in double quotes (" ")
Example: 'A' Example: "Hello"
Uses char data type Uses String class
Usually fixed small memory Memory depends on string length

2. Difference between = and ==


= ==
Assignment operator Comparison operator
Assigns value to variable Compares two values
Example: x = 5 Example: x == 5
Does not return true/false Returns true or false

3. Primitive vs Non■Primitive Data Types


Primitive Data Types Non■Primitive Data Types
Basic built■in data types Derived or complex data types
Store single value Can store multiple values or objects
Simpler and faster More complex
Examples: int, char, float, boolean Examples: String, Array, Class, Object

4. [Link]() vs [Link]()
[Link]() [Link]()
Used to calculate power of a number Used to calculate square root
Syntax: [Link](a,b) Syntax: [Link](x)
Returns a raised to power b Returns √x
Example: [Link](2,3)=8 Example: [Link](25)=5

5. [Link]() vs [Link]()
[Link]() [Link]()
Returns nearest integer as double Returns nearest integer value
May return even integer when exactly halfway Rounds up when decimal ≥ 0.5
Return type: double Return type: int or long
Example: [Link](5.5)=6.0 Example: [Link](5.5)=6

6. Prefix vs Postfix
Prefix (++x) Postfix (x++)
Value increases first then used Value used first then increases
Increment before expression Increment after expression
Example: y = ++x Example: y = x++

7. Compilation Error vs Logical Error vs Runtime Error


Compilation Error Logical Error / Runtime Error
Occurs during compilation Occurs during execution or due to wrong logic
Program does not run Program runs but wrong output or crashes
Caused by syntax mistakes Caused by wrong logic or illegal operations
Example: missing ; Example: divide by zero or wrong formula

8. Entry Control Loop vs Exit Control Loop


Entry Control Loop Exit Control Loop
Condition checked before loop body Condition checked after loop body
May execute zero times Executes at least once
Examples: for, while Example: do■while

You might also like