You are on page 1of 1

SNIPPET OF REQUIREMENT

Write a program in Java to read a configuration file in following format and return the value of
variables

Var1 = Value1
Var2 = Value2
Section-1
Var1 = Value1.0
Var3 = Value3.0
Sub-section-1
Var1 = Value1.1
Var2 = Value2.1

Sub-section-1_1
Var1 = Value1.1_1
Sub-Section-2
Var2 = Value2.2
Var3 = Value3.2
Section-2
Var1 = Value1.0

Sub-section-1
Var1 = Value1.1
Var2 = Value2.1

EVALUTATION

The code will be judged on following qualities (in the order):


o Correctness of the logic
o Modularization, Structure & Quality of the code
o Simple readable code is preferred over very complex but slightly more efficient
o Memory & CPU utilization
Feel free to write any inline code comments to document or any test cases that you would like
to test the code with
Feel free to utilize any standard libraries (& any open source software)
Feel free to make assumptions but state them clearly

RULES

There can be multiple Sub sections in a section


There can be multiple sub sections in each sub section recursively (assume max limit of 5)
You need to parse the file and implement a function as following
o public String getValue(String var) {}
o Var will be passed in the form of Section-1::Sub-Section-1::Sub-Section1_1::Var1
Return value should contain the innermost value of the configuration
If the Var does not exist in innermost Sub-section then it should be recursively picked up from
outer one till the global
If the entire Sub-Section in the chain does not exist then you should return the innermost till
the chain exists
If the variable does not exist return NULL
Your solution should be submitted within 3 days, ideally you should not need to spend more
than 3 to 4 hours.
Submit code as if you were deploying it on production.

You might also like