in Combinatory
1,086 views
0 votes
0 votes
The name of a variable in the JAVA programming language is a string of between $1$ and $65,535$ characters, inclusive, where each character can be an uppercase or a lowercase letter, a dollar sign, an underscore, or a digit, except that the first character must not be a digit. Determine the number of different variable names in JAVA.
in Combinatory
by
1.1k views

2 Answers

0 votes
0 votes
Given string is between 1 and 65,535 inclusive.

Given each character can be

Lowercase letter = 26

Uppercase letter = 26

Dollar sign =1

Underscore =1

Digits = 10 (1 to 10).

First letter cannot be digit, so it has 54  possibilities only( 26 + 26 + 1 + 1)

Remaining 65,534 characters can have  64 possibilities ( 26 + 26 + 1 + 1 + 10).

∴ Total Possibilities = $54$ x $65,534^{64}$

The number of different variable names in JAVA are $54$ x $65,534^{64}$
0 votes
0 votes
In Practice, Java with one character variable name cannot be contained _ so

1 -> 53 possibility  i.e 26 + 26 + 1

2 -> 54 * 64

3 -> 54 * 64^2

4 -> 54 * 64^3

.

.

.

.

65534 -> 54 * 64^65534

after the G.P series simplification

53 + 54((64^65535 - 1)/63) - 54

Related questions

Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true