Java

Ace your homework & exams now with Quizwiz!

What version of java are you using and why that version?

I have used Java 8 for many years. In My recent project, I am using Java 11 LTS version.

What are the differences between a class and an object?

A class is a blueprint An object is the physical result of the class (blueprint à building) An object is the instance of a class GIVE AN EXAMPLE OF A RECIPE I define all structures all behaviors of objects in the class

What are the lengths of an empty String and a null String?

An empty String has no characters so that the length would be 0 A null String means there is no String object. Null is a placeholder for objects If we tried getting the length on the null, we would get NullPointerException.

How would you rate your Java skills out of 10?

Being around 7 or 8 is good.There is also more to learn especially for the topics that I. don't use as a SDET. But I am able to read and use any java library

How can you access the last element in an array?

Got it. This is something we do pretty often.There is general formula for that length-1 why is length-1 because indexes starts from zero.

Why do you use Java instead of any other language?

I am using Java because it is my first language; more i use it more I like it. From a technical perfection, it is platform-independent. Also, it is a high-level language. If you have a Java background, it is easy to understand low-level languages and other languages. I am familiar with libraries like selenium for UI testing, JDBC for database testing, and RestAssured for API testing.

Do you only have experience using java for testing or have you used it for other areas like development?

I mainly use it for Testing, but sometimes I am found myself kind of looking around and playing around like discord bots... something like JDA Library. But definitely enjoy testing with Java. However, I have more passion for testing. I am definitely interested to learn more always

How many years have you been using java for testing?

It is about five years

Can you describe how you would reverse a String in java?

Sure, If I have a string in Java, If I need to reverse it, I probably set up a loop, a traditional loop, I need to start from the last index. length-1 presents the last index, and then I go until zero ( including zero), which presents the first character.This how I set up to loop.Then All I need to use CharAt() method from string class it helps me to read character in String.If I need to get string back as a reverse.I just need to append them.

What is Java String Pool?

The String pool is a special memory location for String literals. It memory in the heap to store strings. It provides better performance and memory management Does not create duplicate values, allows references to the same objects The string created using the new keyword is created in heap directly like other objects. In string literals java stores string sequence. It helps us to reach easily...Doesnt allow duplications.

What is the difference between continue and break in loops?

The break statement will stop the loop as soon as it is run The continue statement will stop the current iteration and go to the next iteration. This means, let's say it is on 5th iteration, it not execute it will continue 6th iteration These statements should not be used too much

How can you find the second biggest number in an array?

The first thing that comes to my mind is kind of quick way to sort the array of the element at length-2 index. If we needed to do this all ourselves without sorting we could keep 2 variables to hold the max and second max values. We would iterate through the numbers in the array and check two conditions: the first condition would check if we found a new max number. In this case the old max would become the second max value and the new max number would be changed to the current element the second condition to check would be if the current element was bigger than the current second max but less than the max number and in that case we would update our second max variable with that current element By the end of the loop, we would have our max and second max numbers

How would you find the max value in an int array?

The immediate thought is to sort the array and read the last index because that will be the biggest value. First, I need to create a variable to track the biggest number. The first element can be used as the initial value/ I can go with for each loop because I don't need their index number. Then iterate through all the other elements. During each iteration, we would compare the element with the biggest number variable we declared in the beginning. Whenever the current iterated element is bigger than the previous one, we could reassign our biggest number to that number This checking would continue until the end of the loop, and at that point, the biggest number variable would be holding our max value.

What is the difference between the Heap and the Stack?

These are two memory components in Java. Stack kind of temporary storage place it holds method frames, local variables, references, But the heap area where we store our objects also string pool.

Describe how you would sort an Array, without using built in methods?

To implement the algorithm I would declare a loop that iterates through each index of the array Then I would create a nested loop that will start from 0 and go until the end of the array, but with some restations based on the next steps In the inner loop I would need to compare the 2 elements next to each other. If the current element was bigger than the element next to it (index + 1) and I would swap the position of the two elements By doing this I will be able to move the bigger numbers to the end and keep doing this for each index of the array

How would you reverse a sentence without reversing each individual word?

You want me reverse each individual words dont want me to reverse characters.Ok I got it.I know every word sperated by space so i can use split() method on string.Then I can put each word into a String Array. Starting from last index of Array read the element and concatenate each element into the order we wanted In the end we have the original sentence in reverse, but the words themselves would not be reversed


Related study sets

NURSING 212 EXAM 1- PSYCHOSOCIAL COPING OF CHILDREN AND FAMILIES IN CRISIS

View Set

NIMS Testing (100% - glance at it)

View Set

EMT - Chapter 35: Geriatric Emergencies

View Set

Words for Hoi ik lees Ivriet deel 1

View Set

AP Macro Econ Unit 1 Study Guide

View Set

Social Problems Test Two, Chapter 5

View Set