TRENDING NEWS

POPULAR NEWS

A Little Help With These Java Concepts

Need help with Java!?

This is a little bit of just-for-fun work my teacher gave me, but I'm not sure how to go around doing any of these. Can someone show me? Thanks!



Imagine a card game in which the objective is to get a collection
of cards with a total score of 21. The total score for a hand is the total of the scores
for all the cards. The score for each card is as follows: aces count as 1, all face cards
count as ten; for all other cards the score is the same as the rank. Example: the hand
(Ace, 10, Jack, 3) has a total score of 1 + 10 + 10 + 3 = 24.
Write a method called handScore that takes an array of cards as an argument and
that adds up (and returns) the total score.

The printCard method takes a Card object and
returns a string representation of the card.
Write a class method for the Card class called parseCard that takes a String and
returns the corresponding card. You can assume that the String contains the name of
a card in a valid format, as if it had been produced by printCard.
In other words, the string will contain a single space between the rank and the word
“of,” and between the word “of ” and the suit. If the string does not contain a legal
card name, the method should return a null ob ject.
The purpose of this problem is to review the concept of parsing and implement a
method that parses a specific set of strings
.
Write a method called suitHist that takes an array of Cards as a
parameter and that returns a histogram of the suits in the hand. Your solution should
only traverse the array once.

Write a method called isFlush that takes an array of Cards as a
parameter and that returns true if the hand contains a flush, and false otherwise. A
flush is a poker hand that contains five or more cards of the same suit.

Encapsulate this deck-building code in a method called buildDeck
that takes no parameters and that returns a fully-populated array of Cards.

int index = 0;
for (int suit = 0; suit <= 3; suit++) {
for (int rank = 1; rank <= 13; rank++) {
deck[index] = new Card (suit, rank);
index++;
}
}

Which java concepts do I need to learn before proceeding to servelets and JSP?

Hi,You should first learn Core Java and advanced Java. After that you can learn JSP and Servlet.Here are the links of best Core Java tutorials:How to Get Started with Java?Installing Java (JDK 7) on Windows 7 Computer Video TutorialLearn Java in a dayMaster Java In A WeekFrameworksJSP TutorialsJava : Servlet TutorialsJDBC - Java Database Connectivity TutorialWelcome to the MySQL TutorialsJava Example Codes and TutorialsHow to install Java 8?Advanced JavaThese are the tutorials of Advanced Java:Advanced Java TutorialsCore Java Basics Help, Core Java Beginners Guide, Core Java Online Tutorials & HelpJSP, Servlets, JDBC and MySQLNow you can learn JSP and Servlet with the help of following tutorials:JSP TutorialsJava : Servlet TutorialsJDBC - Java Database Connectivity TutorialWelcome to the MySQL TutorialsThaks

What are the most important concepts in Java, that should be learned and reviewed before a technical interview?

Some of them can be considered as Interview questions rather than a "topic" in Java.But,I will help you with the concepts I find in Java are important.And,please note,I am not asking yo your experience in Java,so I am assuming you would be having a little or atleast 1/2 years of experience in Java?If not,the following would still help.Basic Knowledge:Basic principles of Object Oriented ProgrammingPolymorphismSOLID(Single Responsibility Principle,Open/Close Principle ,Liskov Substitution Principle,Interface Segregation Principle,and Dependency Inversion Principle)principles in object-oriented programmingStatic methods and static variablesinstance variables and methodsConstructors and InheritanceDeep copy vs Shallow copyMethod overloading/Method Overriding which follows with the question -> difference between method overloading vs method overridingdifference between final,finally,and finalizedifference between Runtime polymorphism,and Compile time polymorphismdifference between Abstract class and interfaceException handling in JavaStrings and immutability may be asked during a phone interview,but may not always:Threads in JavaMultithreading in JavaCollections:These include and not limited to:LinkedListsArrayLists HashMapHashSet,SetThen there are questions like:Difference between LinkedLists and ArrayList.Difference between LinkedLists and a Set.Difference between a HashMap vs a HashSetThen there is a topic that most of the companies would like to ask about is Design Patterns- Singleton- Factory- Abstract Factory- Builder- Visitor Lastly,I would like to conclude by saying,now that Java 8 is in the market, and I assume you would be aware that it has some "functional" aspect to it,you may expect questions on:- Streams API in Java- forEach() method on iterable interfaces- Concurrency API- Collections API improvements- Lambda expressions- Interface default and static methods- method references- parameter names- use of Optional and many more,I cannot think of right now.Some content online:http://www.javacodegeeks.com/201...Some of the questions/answers I found on Quora: What are good interview questions for Java developers?Let me know if that helps!

What are the concepts every Java programmer must know?

These are few basic concepts that I found useful:Abstraction and Encapsulation - Java programmer must know difference Abstraction and Encapsulation and how these can be utilized in java. A good understanding of POJOs and why we need POJOs will always help you designing a better solution.Difference between equals and "== "operator - "==" operator compares the if instances refer to the same object. Whereas equals() is a method defined in Object class of java. equals() is used to compare the content of an object.Collections - A good knowledge of collection can save you from many performance issues. It is always advisable know about:Difference between list, set and map.Difference between LinkedList and ArrayList - Arraylist is pretty fast for search operations however Linkedlist is good for fast addition and deletion.Difference between HashSet and TreeSet - HashSet is usually faster than Treeset if you are not bothered about sorting elements.Difference between HashMap, HashTable and ConcurrentHashMap - Use of maps can be a bit tricky if you are trying to access them concurrently.Contract between equals and hashCode - You may or may not use the concept but it is always good to know how java operates internally.Difference between an Abstract class and Interface - With Java 8 features, now it is even more important to know about Interfaces.Difference between Instance variable and class variable - I have seen many programmer struggling with the concept of instance variable and class variable. Instance variable belongs to an object and every object will have its own copy of instance variable. Whereas a copy of class variable will be shared among all the objects of class.This list is long you can keep learning, but the concepts that I have listed made my life a little easier while coding.Hope that helps.Happy coding.

Help with Java Strings Variables?

1. firstName + " " + middleName + " " + lastName

The "+" is Java's "concatenation" symbol when it is used with strings.

2. gold + "\n" + silver + "\n" + bronze

HELP!! in Java programming?

yes I did try each one separately , however it ended up with FAIL :(
now that I have only 10 days to complete the 5 assignments and 2 projects ..I really have no more time to waste on trying :(

Explain some of the concepts of Java design patterns?

Design Patterns are tremendously more general than Java. They provide insights into aspects of software design and development that represent recurrent problems. These are problems that have been solved effectively and should not be solved over and over again from scratch - identify the problem in terms of a pattern, and you save a huge amount of effort and expense by having an optimal structure for the solution already well understood and thoroughly well specified. These are predominantly Object Oriented (OO) programming issues, but not exclusively so. A pattern describes a general problem in terms of the motives and forces that are at work in the context of that problem. The pattern then demonstrates how to decompose the competing facets of the problem and provides a framework for solutions that optimize the stability and supportability of any implementation based on the pattern.

The original Gang-of-Four (GoF) patterns are widely applied in OO development in Java and other languages. GoF in Java problem-spaces is discussed at greater length at:

http://www.cmcrossroads.com/bradapp/java...

The evolution of patterns as a concept has expanded the patterns universe in many directions. The Model-View-Controller (MVC) complex pattern is now the most ubiquitous approach to decomposing the responsibilities of OO applications. MVC is widely used in Java implementations. Sun has a nice little page about MVC for Java at:

http://java.sun.com/blueprints/patterns/...

In Java, the J2EE (now JEE) model extends the notion of pattern to include a large collection of J2EE patterns peculiar to the servlet specification. The Core J2EE Patterns are available for review at:

http://java.sun.com/blueprints/patterns/...

...with a really pretty picture at:

http://java.sun.com/blueprints/corej2eepatterns/Patterns/index.html

That's the view from orbit.

What books are best or the most helpful for self learning Java programing? Will someone with experience recommend books that are straight forward, gives the basic concepts, and helps one move from beginners level to an advanced?

After reading many questions and answers on here, I have come up with a list of Java programming books that are mentioned quite a lot.Java: A Beginners GuideHead First JavaJava: The Complete ReferenceIntroduction to Java ProgrammingI think Java: A Beginners Guide is a good entry level book for those just starting out in Java programming.Head First Java is a good book, but my only issue is that the latest version is from 2005, which focuses on Java 5.Java: The Complete Reference is also a very good Java programming resource book.If your interested in learning about Lamba Expressions introduced in Java 8, Java 8 Lambdas is a good choice.Best Java Books For Programmers

TRENDING NEWS