About Question enthuware.ocajp.i.v7.2.1377 : (2024)

Moderator: admin

Post Reply

  • Print view

7 posts• Page 1 of 1

Myzreal
Posts: 1
Joined: Mon Jun 16, 2014 6:25 am
Contact:

Contact Myzreal

Send private message

About Question enthuware.ocajp.i.v7.2.1377 :

  • Quote

Postby Myzreal »

Note under option #4 says that "the floating point suffices f, F or d, D are used only when using decimal system or hexadecimal and not while using binary".

However, hexadecimal numbers make use of the F character as a digit. How does the compiler know when we meant to use F as a digit and when as a floating point suffix?

Will the number 0x1f be considered integer 31 or float 1.0f?

Top

admin
Site Admin
Posts: 10150
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Contact admin

Send private message

Re: About Question enthuware.ocajp.i.v7.2.1377 :

  • Quote

Postby admin »

Integer 31. Compiler has no issues figuring that out because any number starting with 0x is in binary and since there is no 'p' or 'P' in the number, it is a decimal. To write a floating point number is binary, there must be a 'p' or 'P' in the number. Please see this for full details: http://docs.oracle.com/javase/specs/jls ... jls-3.10.2

BTW, 'p' and 'P' are not required for the exam.

HTH,
Paul.

If you like our products and services, please help us by posting your review here.

Top

Kevin_C
Posts: 14
Joined: Mon Nov 03, 2014 5:18 am
Contact:

Contact Kevin_C

Send private message

Re: About Question enthuware.ocajp.i.v7.2.1377 :

  • Quote

Postby Kevin_C »

Why are the suffices with binary only invalid for floating points? So, why is this invalid:

Code: Select all

float x = 0b100f;

but this valid:

Code: Select all

long x = 0b100L;

Also, is there a difference between lower-case and upper-case? Or is f and F the same, d and D the same, l and L the same?

Top

admin
Site Admin
Posts: 10150
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Contact admin

Send private message

Re: About Question enthuware.ocajp.i.v7.2.1377 :

  • Quote

Postby admin »

That is how the language designers designed this feature. There is no technical limitation that prevents it.

There is no difference between lower and upper case.

HTH,
Paul.

If you like our products and services, please help us by posting your review here.

Top

gparLondon
Posts: 63
Joined: Fri Oct 31, 2014 6:31 pm
Contact:

Contact gparLondon

Send private message

Re: About Question enthuware.ocajp.i.v7.2.1377 :

  • Quote

Postby gparLondon »

Hi,

What else should we know about octal, hexadecimal and binary number?

1>I mean should be know the output of the program when they are written?

example :float hexa=0x01dfeacL; System.out.println(hexa);

2>Should we know about the range they take?

example:byte b = 0b1100110011; // Type mismatch: cannot convert from int to byte

Thanks,
GPAR

Top

admin
Site Admin
Posts: 10150
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Contact admin

Send private message

Re: About Question enthuware.ocajp.i.v7.2.1377 :

  • Quote

Postby admin »

No, don't worry about ranges. Just knowing how to write numbers in binary, octal, and hex is enough. No need to translate from one format to another either.

If you like our products and services, please help us by posting your review here.

Top

scranen
Posts: 12
Joined: Thu May 07, 2015 8:55 am
Contact:

Contact scranen

Send private message

Re: About Question enthuware.ocajp.i.v7.2.1377 :

  • Quote

Postby scranen »

Maybe the explanation could be clearer on the difference between integer literals in hexadecimal format and floating point literals in hexadecimal format (recognizable by the 'p' or 'P' exponent indicator).

Code: Select all

float f1 = 0xffff_ffff; // int literal, assigned to a floatfloat f2 = 0xffff_ffffL; // long literal, assigned to a floatfloat f3 = 0xffff_ffff_ffff_ffffL; // Dittofloat f4 = 0xffff_ffff_ffff_ffff; // Not a valid int literal, because the specified number does not fit in an int!float f5 = 0xffff_ffffp0f; // float literal, assigned to a floatfloat f6 = 0xffff_ffffp0; // double literal, assigned to a float: Possible loss of precision!float f7 = 0xffff_ffff_ffff_ffffp0f; // (very large) float literal, assigned to a float

It is useful to know that hexadecimal integer literals (without the 'p') are interpreted as two's complement, whereas floating point literals are interpreted as unsigned numbers.

Code: Select all

System.out.println(f1); // prints -1.0System.out.println(f2); // prints 4.2949673E9System.out.println(f3); // prints -1.0System.out.println(f5); // prints 4.2949673E9System.out.println(f7); // prints 1.8446744E19

Top

Post Reply

  • Print view

7 posts• Page 1 of 1

Return to “OCA OCP Java Programmer Certification Questions Discussion”

Jump to

  • Discussion Forum
  • ↳ OCFA Java Foundations Certified Junior Associate Questions
  • ↳ OCA OCP Java Programmer Certification Questions Discussion
  • ↳ Servlet/JSP Web Component Developer Certification (SCWCD/OCE-WCD/OCWCD) 1Z0-899/1Z0-858
  • ↳ EJB/JPA Certification (SCBCD/OCE-JPA/OCE-EJBD) 1Z0-895/1Z0-898
  • ↳ Java Web Services Developer Certification (OCE-JWS) 1Z0-897
  • ↳ Other Certifications
  • ↳ Time Pass Lounge
  • ↳ Feedback, Suggestions, Comments, Admin Communication
  • ↳ General Java Discussion
  • ↳ Errors/Bugs that have been fixed

Who is online

Users browsing this forum: No registered users and 32 guests

About Question enthuware.ocajp.i.v7.2.1377 : (2024)
Top Articles
Pirated Games Mega Thread Backup
What Are Four Different Kinds Of Graphs And What Makes Them Unique?
Cintas Pay Bill
Ingles Weekly Ad Lilburn Ga
Select The Best Reagents For The Reaction Below.
Bank Of America Appointments Near Me
CHESAPEAKE WV :: Topix, Craigslist Replacement
Ou Class Nav
Craigslist Greenville Craigslist
Assets | HIVO Support
Johnston v. State, 2023 MT 20
Robert Malone é o inventor da vacina mRNA e está certo sobre vacinação de crianças #boato
Craigslist Pets Sac
Busty Bruce Lee
Lesson 8 Skills Practice Solve Two-Step Inequalities Answer Key
Ostateillustrated Com Message Boards
Idaho Harvest Statistics
Soccer Zone Discount Code
Las 12 mejores subastas de carros en Los Ángeles, California - Gossip Vehiculos
360 Tabc Answers
Vrachtwagens in Nederland kopen - gebruikt en nieuw - TrucksNL
Daylight Matt And Kim Lyrics
Scotchlas Funeral Home Obituaries
north jersey garage & moving sales - craigslist
Grimes County Busted Newspaper
Teen Vogue Video Series
If you have a Keurig, then try these hot cocoa options
Teekay Vop
Mdt Bus Tracker 27
Geico Car Insurance Review 2024
What we lost when Craigslist shut down its personals section
Reserve A Room Ucla
Past Weather by Zip Code - Data Table
Tripcheck Oregon Map
Bad Business Private Server Commands
Whas Golf Card
Marie Peppers Chronic Care Management
Craigslist Lakeside Az
Elizaveta Viktorovna Bout
The Transformation Of Vanessa Ray From Childhood To Blue Bloods - Looper
How Does The Common App Work? A Guide To The Common App
VPN Free - Betternet Unlimited VPN Proxy - Chrome Web Store
Dickdrainersx Jessica Marie
Oklahoma City Farm & Garden Craigslist
Streameast Io Soccer
Egg Inc Wiki
Bismarck Mandan Mugshots
Wild Fork Foods Login
Skyward Login Wylie Isd
Rise Meadville Reviews
Unity Webgl Extreme Race
Olay Holiday Gift Rebate.com
Latest Posts
Article information

Author: Gregorio Kreiger

Last Updated:

Views: 5920

Rating: 4.7 / 5 (57 voted)

Reviews: 80% of readers found this page helpful

Author information

Name: Gregorio Kreiger

Birthday: 1994-12-18

Address: 89212 Tracey Ramp, Sunside, MT 08453-0951

Phone: +9014805370218

Job: Customer Designer

Hobby: Mountain biking, Orienteering, Hiking, Sewing, Backpacking, Mushroom hunting, Backpacking

Introduction: My name is Gregorio Kreiger, I am a tender, brainy, enthusiastic, combative, agreeable, gentle, gentle person who loves writing and wants to share my knowledge and understanding with you.