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 4 guests

About Question enthuware.ocajp.i.v7.2.1377 : (2024)
Top Articles
tweedehands auto kopen in Eindhoven
PhD on hardware design of RDC for Electric Vehicle Fast Chargers (E2GO DC1)
Vegas X Vip.org
Foodsmart Jonesboro Ar Weekly Ad
What Is Flipping Straights Ted Lasso
Sinai Web Scheduler
Uta Frontrunner Twitter
Think Up Elar Level 5 Answer Key Pdf
Emily Katherine Correro
Eliud Kipchoge Resting Heart Rate
1v1 lol unblocked Game- Play Unblocked Game Online for Free!
Cox Teacher Discount
Names of the dead: September 11, 2001
Cavender’s 50th Anniversary: How the Cavender Family Built — and Continues to Grow — a Western Wear Empire Using Common Sense values
Henry Metzger Lpsg
Peak Gastroenterology Associates Briargate
Sloansmoans Many
Daves Supermarket Weekly Ad
Pull And Pay Middletown Ohio
NFL Week 1 games today: schedule, channels, live streams for September 8 | Digital Trends
Wisconsin Public Library Consortium
Who Is Acropolis 1989? Wiki, Bio, Age, Boyfriend, Net Worth | Biography Lane
Sweeterthanolives
Bureaustoelen & Kantoorstoelen - Kantoormeubelen | Office Centre
What Are The Hours Of Chase Bank Today
Odu Csnbbs
Recharging Iban Staff
Withers Not In Sarcophagus
Best Turntables of 2023 - Futurism
24 Hour Pharmacy Berkeley
Nahant Magic Seaweed
Erie Pa Craigslist
EnP. Karl Sam Maquiling on LinkedIn: #anniversary #localgovernment #urbanplanning #goodgovernance…
Alylynn
Aces Fmc Charting
Glowforge Forum
Slmd Skincare Appointment
Its Arrival May Be Signaled By A Ding
The Nun 2 Ending Explained, Summary, Cast, Plot, Review, and More
Directions To Pnc Near Me
Kayky Fifa 22 Potential
8569 Marshall St, Merrillville, IN 46410 - MLS 809825 - Coldwell Banker
Netdania.com Gold
Ap Chem 2022 Frq Scoring Guidelines
Unit 8 Homework 3 Trigonometry
C Weather London
Henry Ford Connect Email
Craigslist Pgh Furniture
Carenow Urgent Care - Eastchase Fort Worth Photos
Nfl Espn Expert Picks 2023
Bbw Chan Lmbb
Latest Posts
Article information

Author: Pres. Carey Rath

Last Updated:

Views: 6181

Rating: 4 / 5 (61 voted)

Reviews: 92% of readers found this page helpful

Author information

Name: Pres. Carey Rath

Birthday: 1997-03-06

Address: 14955 Ledner Trail, East Rodrickfort, NE 85127-8369

Phone: +18682428114917

Job: National Technology Representative

Hobby: Sand art, Drama, Web surfing, Cycling, Brazilian jiu-jitsu, Leather crafting, Creative writing

Introduction: My name is Pres. Carey Rath, I am a faithful, funny, vast, joyous, lively, brave, glamorous person who loves writing and wants to share my knowledge and understanding with you.