Hello Programmers/Coders, Today we are going to share solutions of Programming problems of HackerRank of Programming Language Java . At Each Problem with Successful submission with all Test Cases Passed, you will get an score or marks. And after solving maximum problems, you will be getting stars. This will highlight your profile to the recruiters.
In this post, you will find the solution for Java Static Initializer Block -HackerRank Problem. We are providing the correct and tested solutions of coding problems present on HackerRank. If you are not able to solve any problem, then you can take help from our Blog/website.
Use “Ctrl+F” To Find Any Questions Answer. & For Mobile User, You Just Need To Click On Three dots In Your Browser & You Will Get A “Find” Option There. Use These Option to Get Any Random Questions Answer.
Introduction To Java
JAVA was developed by James Gosling at Sun Microsystems Inc in the year 1991, later acquired by Oracle Corporation. It is a simple programming language. Java makes writing, compiling, and debugging programming easy. It helps to create reusable code and modular programs.
Java is a class-based, object-oriented programming language and is designed to have as few implementation dependencies as possible. A general-purpose programming language made for developers to write once run anywhere that is compiled Java code can run on all platforms that support Java. Java applications are compiled to byte code that can run on any Java Virtual Machine. The syntax of Java is similar to c/c++.
Link for the Problem – Java Static Initializer Block – Hacker Rank Solution
Java Static Initializer Block – Hacker Rank Solution
Problem :
Static initialization blocks are executed when the class is loaded, and you can initialize static variables in those blocks.
It’s time to test your knowledge of Static initialization blocks.
You are given a class Solution with a main method. Complete the given code so that it outputs the area of a parallelogram with breadth B and height H . You should read the variables from the standard input.
If B ≤0 or H≤0 , the output should be “java.lang.Exception: Breadth and height must be positive” without quotes.
Input Format
There are two lines of input. The first line contains : the breadth of the parallelogram. The next line contains : the height of the parallelogram.
Constraints
- -100 ≤ B ≤ 100
- -100 ≤ H ≤ 100
Output Format
If both values are greater than zero, then the main method must output the area of the parallelogram. Otherwise, print “java.lang.Exception: Breadth and height must be positive” without quotes.
Sample input 1
1 3
Sample output 1
3
Sample input 2
-1 2
Sample output 2
java.lang.Exception: Breadth and height must be positive
Java Static Initializer Block – Hacker Rank Solution
import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { // Java Static Initializer Block - Hacker Rank Solution START static boolean flag; static int B,H; static{ Scanner io = new Scanner(System.in); B = io.nextInt(); H = io.nextInt(); if(B>0 && H>0) { flag = true; } else { System.out.println("java.lang.Exception: Breadth and height must be positive"); } } // Java Static Initializer Block - Hacker Rank Solution END public static void main(String[] args){ if(flag){ int area=B*H; System.out.print(area); } }//end of main }//end of class
I’ve read several just right stuff here. Certainly value bookmarking for revisiting. I surprise how much effort you set to create the sort of wonderful informative web site.
Would love to perpetually get updated outstanding weblog! .
I savor, lead to I found exactly what I used to be having a look for. You’ve ended my 4 day lengthy hunt! God Bless you man. Have a nice day. Bye
When I originally commented I clicked the -Notify me when new comments are added- checkbox and now each time a comment is added I get four emails with the same comment. Is there any way you can remove me from that service? Thanks!
I would like to thnkx for the efforts you have put in writing this blog. I am hoping the same high-grade blog post from you in the upcoming as well. In fact your creative writing abilities has inspired me to get my own blog now. Really the blogging is spreading its wings quickly. Your write up is a good example of it.
An fascinating dialogue is price comment. I think that you need to write extra on this subject, it won’t be a taboo topic however generally individuals are not enough to talk on such topics. To the next. Cheers
Perfect work you have done, this internet site is really cool with excellent info .
I really prize your piece of work, Great post.
I know this if off topic but I’m looking into starting my own weblog and was curious what all is required to get set up? I’m assuming having a blog like yours would cost a pretty penny? I’m not very web smart so I’m not 100 certain. Any recommendations or advice would be greatly appreciated. Appreciate it
Very fantastic visual appeal on this internet site, I’d rate it 10 10.
I love your blog.. very nice colors & theme. Did you create this website yourself or did you hire someone to do it for you? Plz respond as I’m looking to construct my own blog and would like to find out where u got this from. appreciate it
Hey! I know this is kinda off topic but I was wondering which blog platform are you using for this site? I’m getting sick and tired of WordPress because I’ve had problems with hackers and I’m looking at options for another platform. I would be fantastic if you could point me in the direction of a good platform.
Dead composed written content, thanks for entropy.
I was reading through some of your articles on this website and I think this site is really informative ! Keep putting up.
I went over this internet site and I think you have a lot of excellent information, saved to fav (:.
I do not even understand how I finished up right here, however I thought this post was great. I do not realize who you’re but definitely you are going to a well-known blogger for those who aren’t already 😉 Cheers!
cialis 20mg cheap order tadalafil 5mg for sale best ed pill
Very efficiently written story. It will be supportive to everyone who employess it, as well as myself. Keep up the good work – for sure i will check out more posts.
I truly enjoy reading through on this website , it contains wonderful content. “Wealth and children are the adornment of life.” by Koran.
Hiya very nice site!! Man .. Excellent .. Amazing .. I will bookmark your blog and take the feeds also…I am happy to search out a lot of helpful information here within the submit, we need work out more strategies in this regard, thank you for sharing. . . . . .
cefadroxil online cefadroxil 250mg pill buy propecia for sale
It is in reality a nice and helpful piece of info. I am satisfied that you just shared this helpful information with us. Please stay us up to date like this. Thank you for sharing.
metronidazole tablet order bactrim 960mg online oral cephalexin 125mg
order cleocin 150mg sale buy fildena 100mg pill best ed pills non prescription
order tamoxifen 20mg pills nolvadex pills order generic ceftin 500mg
buy generic bimatoprost buy robaxin for sale desyrel 50mg pills
Get the latest updates on new products and upcoming sales Playing cards is a favorite pastime for family and friends. Whether it’s an impromptu game during the holidays or a regularly scheduled poker night, a poker table is a convenient and comfortable way for you to play those card games in style. Poker Table Covers IN STOCK TABLES SHIP FREE THE NEXT DAY IF ORDERED BY 11PM CENTRAL TIME! From cheap, portable, rolled up cloth mats, to high-end luxury professional models, I hope to have given you a good review of the best poker table options there are out there and an idea of how much each type costs. If you found this article informative, be sure to browse the resources section of our site, and let us know if there is a subject you would like addressed in the comments below. Also, feel free to browse our site to learn more about poker strategy. Thanks for stopping by!
http://songamnano.com/new/bbs/board.php?bo_table=free&wr_id=35090
On top of a mouth-watering welcome package. Omni Casino runs at least one promotion each day of the week for all existing customers. Weekly promotions are published on the website and sent out to all customers every Friday via the Omni Times (Omni Casinos newsletter) daily promotions differ day to day. As well as daily promotions Omni Casino also has its fixed customer promotions, the most famed is known as the HotSeat. The HotSeat runs weekly and awards active customers for their activity. Disclaimer: This website is an informational site and should be used for informational purposes only. We pride ourselves on having the most up to date information but cannot guarantee 100% accuracy. Please check your local laws regarding online gambling to ensure that you are in compliance with the laws of your jurisdiction. Gambling can be addictive, please play responsibly.
order sildenafil 50mg sale buy aurogra without prescription sildenafil pills 100mg
isotretinoin sale order isotretinoin 20mg generic buy azithromycin pill
lasix canada oral albuterol ventolin buy online
buy vardenafil 10mg generic vardenafil without prescription order plaquenil generic
I discovered your blog site on google and check a few of your early posts. Continue to keep up the very good operate. I just additional up your RSS feed to my MSN News Reader. Seeking forward to reading more from you later on!…
purchase altace online cheap buy altace without a prescription order arcoxia 60mg without prescription
vardenafil online buy hydroxychloroquine medication brand hydroxychloroquine
order asacol online cheap cheap asacol 800mg order irbesartan online
benicar 10mg pills purchase depakote online buy divalproex without a prescription
buy carvedilol 25mg generic buy aralen 250mg generic how to get aralen without a prescription