The Highest Post
Java Top questions

Find by name:


New Post

Recent Post

  • Samson Koa What is Java Virtual machine?

    It acts as a translator between the Java code you write and the machine code your operation system expects

    Peter Agyekum What does it mean, when code is written in discrete units of related code?

    Well, those units are called classes, and from classes, you “instantiate” “objects.”

    Peter Agyekum What is the first line in a class?

    The first line in a class is the word package, which is a reserved word, or keyword. This means that “package” has a defined use, and acts as an instruction for the JVM

    Peter Agyekum What is the the second line of a class ?

    The second line is the class declaration. It consists of an access modifier, followed by the reserved word “class,” then the name of the class, and finally the curly braces that wrap around the contents of the class.

    Peter Agyekum What is access modifiers in Java?

    Access modifiers for a class determine the scope other classes can access the code contained in this class for their own use. They can either be public or left blank meaning default.

    Peter Agyekum How do you name your class?

    When naming your classes it is considered a best practice to use nouns, and they are always written by capitalizing the first letter of each word in the name. The curly braces indicate a change in scope. As a general rule, code written in a lower or “deeper” scope is isolated from code in a higher or shallower scope. In addition to the mandatory curly braces, nested scopes are indented for easier understanding.

    Peter Agyekum What is a method

    A method is a set of instructions that may or may not take in some values, and may or may not return some value

    Peter Agyekum What is examples of method's Access Modifier?

    Methods have an access modifier which can be one of public, private, protected, or left blank, which implies the default access level. The next term is the return type for the method, and void indicates that the method returns no values

    Peter Agyekum What is static in Java?

    static is a scope keyword that means the method exists before an object of the class is instantiated. To say it another way, Static means that the method belongs to the class NOT the object. In fact, it is globally visible to all instances of the class. The main method is static because the JVM needs to be able to access the method without creating an instance of the class that contains it – that would require another class and method in which it would do so, and another for instantiating that class, etc. Void is the return type for this method and means that nothing is returned

    Peter Agyekum Give some characteristics of Java?

    1.) code can be written in discrete(individually separate and distinct) and related units. 2.) Java is also platform-independent, which means you only have to write your code once, and it can be run on any system, due to Java Virtual Machine – which acts as a translator between the Java code you write, and the machine code your operating system expects. Every platform – Windows, OSX, Linux, Android, etc – have their own JVMs, but the Java code they each interpret is universal.

    Peter Agyekum Explain more on discrete units of related code?

    OK, those units are called classes, and from classes, you “instantiate” “objects.”

    Peter Agyekum what steps need to follow to write your java program?

    1) packages, 2) The class declaration consists of an access modifier, followed by the reserved word “class, 3) The name of class 4) Curly braces that wrap around the contents of the class

    Peter Agyekum Describe the variables in Java?

    Primitive and reference variables. Primitive variables are data types like integers, decimals, and alphanumeric characters. Reference variables store memory addresses where Objects are located and are strongly typed too – a reference variable has a type that is the class whose objects the reference variable can point to. Primitives variable types are called “primitive” because they hearken back to a time before Object-Oriented Programming and reference variables were a thing. Primitive types of variables take up specific, predefined amounts of space in memory, and a range of values they can store.

    Peter Agyekum How may primitive data types in Java?

    There are eight primitive data types in Java. 0 for numbers, false for boolean (holds a value of true or false, requires one bit of memory), and the null character for chars. Integer holds a value of true or false, and so it only requires one bit of memory. A float is a 32-bit floating-point number. A short is a 16-bit two’s complement integer, and it ranges from -2^15 to 2^15-1. A float is a 32-bit floating-point number, which means it can store decimal values. A double is a 64-bit floating-point number, Reference variables, on the other hand, use a class name as their type.

    Peter Agyekum What does assignment operator do?

    The assignment operator – commonly known as the equals sign – assigns value to a variable. The assignment operator works right to left, meaning whatever exists on the right side of the equals sign is worked through and stored in the variable on the left side. Simply put, in Java we say X = 3, not 3 = x

    Peter Agyekum What is An array?

    An array is a collection of primitive values or object references, stored in a single variable with an index. You can think of an array as a row of boxes, where the first box is “index 0,” the next is “index 1” and so forth. Has fixed length or number or data type,

    Peter Agyekum How does an Array instantiated?

    You can instantiate an array in one of two ways: you can use the new keyword to create an empty array of a certain size. That syntax looks like this if you wanted to create an array of 10 ints. You could also initialize an array with its values directly, using curly braces as shown. This will create an int array of size 3, which comes preloaded with the values 2, 4, and 6 Accessing a value in an array is as simple as using the variable name, followed by the desired index between brackets. You can also use this syntax to store a value directly to an index in an array. All arrays have a built-in length property, which stores the number of indices the array possesses

    Peter Agyekum What is JavaScript prototype?

    Prototypes are the mechanism by which JavaScript objects inherit features from one another. In this article, we explain how prototype chains work and look at how the prototype property can be used to add methods to existing constructors.

    Peter Agyekum What is Functional Interface in Java?

    A functional interface is an interface that contains only one abstract method. They can have only one functionality to exhibit. From Java 8 onwards, lambda expressions can be used to represent the instance of a functional interface. A functional interface can have any number of default methods.J

    Peter Agyekum lambda expression in java 8?

    Lambda Expressions were added in Java 8. A lambda expression is a short block of code which takes in parameters and returns a value. Lambda expressions are similar to methods, but they do not need a name and they can be implemented right in the body of a method.

    agyekumessien@yahoo.com What are the four Garbage memory collectors in Java?

    1) Serial: singled threaded. 2) Parellel ( multi-threaded -aka throughput), 3) Garbage -first (G1: for server environment), 4) Cuncurent mark Sweep (CMS: short pause, share resources)