Save
Busy. Please wait.
Log in with Clever
or

show password
Forgot Password?

Don't have an account?  Sign up 
Sign up using Clever
or

Username is available taken
show password


Make sure to remember your password. If you forget it there is no way for StudyStack to send you a reset link. You would need to create a new account.
Your email address is only used to allow you to reset your password. See our Privacy Policy and Terms of Service.


Already a StudyStack user? Log In

Reset Password
Enter the associated with your account, and we'll email you a link to reset your password.
focusNode
Didn't know it?
click below
 
Knew it?
click below
Don't Know
Remaining cards (0)
Know
0:00
Embed Code - If you would like this activity on your web page, copy the script below and paste it into your web page.

  Normal Size     Small Size show me how

Java NumStr

QuestionAnswer
It is necessary to add f after the float value while using precision. TRUE Explanation : When we have decimal value with precision that we will double by default. To specify that the value is float then we need to post-fix the value with f.
Which of these declarations hold the value 100? i.int octal = 0144; ii.int binary = 0b1100100; iii.int hexaDecimal = 0x64; i,ii and iii. Explanation : For octal, binary, and hexa the values are prefixed with 0,0b,0x respectively.
public class Main { public static void main(String[] args) { int num1=11; int num2=011; System.out.println(num1 == num2); } } false Explanation : If we add zero before a number, the value will become octal number. The octal number is converted into decimal value and assigned to int variable. The value of num1 is 11 and value of num2 is 9 that are not equal.
We can convert char to int with exact numeric value of char? TRUE Explanation : Yes, we can convert char to int with exact numeric value using wrapper class. For e.g., char c = '9'; int i = Character.getNumericValue(c);
We have to create object to use Character.getNumericValue() FALSE Explanation : getNumericValue() is a static method of Character wrapper class. For static methods, we don't need objects to access
What happen if we directly assign the value of char D to int result? What will be the value of result? 68 Explanation : If we directly assign the value of char to int, it will assign the ASCII value.
Math.random() and new Random().nextDouble() method gives the same result. TRUE Explanation : Math.random() will give the random number in double datatype which uses nextDouble() from Random class. So, both the methods will give the same value.
public class Main { public static void main(String[] args) { int i = 1234; String s = Integer.toString(i); System.out.println(s); } } "1234" //It will give string 1234 Explanation : toString() will convert the given integer to the String data type.
Which method will consider the spaces as seperation between each inputs? next() Explanation : next() will consider the spaces as separation between each inputs. nextLine() will consider the line itself as a input with spaces.
public class Main { public static void main(String[] args) { int i = 1234; String s = String.format("%08d",i ); System.out.println(s); } } 00001234 Explanation : If we add leading zeros in the left side of int type, it will become octal number. We convert the number into String and add leading zeros. We can use format() static method from String
Which of the following methods is used to compare the two strings? equals() Explanation : It returns Boolean based on comparison of two strings.
We can limit decimal precision point. TRUE Explanation : We can limit the precision point using format() static method from String.float f = 12.3456f; String s = String.format("%.2f",f ); System.out.println(s); //12.35.
i.The append() method inserts the value at the last position. ii.The insert() method inserts the value at the last position. Which of the above statements are correct? only i. Explanation : The append() method inserts the value at the last position. The insert() method inserts the value at the specified position.
The methods of StringBuilder are non-synchronized. TRUE Explanation : StringBuilder is in java.lang package. StringBuilder is mutable strings that are stored in heap memory. StringBuilder is non-synchronized methods.StringBuilder is not thread-safe, so the performance is more than StringBuffer.
We can create StringBuilder object of any existing String TRUE Explanation : StringBuilder constructor accepts String object.For e.g.,String s = "Hello";StringBuilder sb = new StringBuilder(s);
We can convert String to int. true
We can convert each word in the sentence as String array. TRUE we have split() method ( String regex) that returns array of strings(String[]) separated by the provided delimiting regular expression. The method returns array of String post delimiting it. We can also give limit to the string.
We can create a string using new keyword. true
String is mutable in Java. FALSE String are sequence of characters in java. String is in java.lang package. String is immutable and are stored inside the string constant pool.
T/F : ii.If we change any the value of the string, the entire string is rewritten and new reference is created. true Hence, the strings are immutable.
T/F : i.If we create a string with the same value, the same reference will be stored to the variable instead of creating new memory. true When create a string using string literal, a memory allocated at the string constant pool a reference assign to variable. Hence, the strings are immutable.
i.StringBuilder is mutable strings that are stored in heap memory. ii.The methods of StringBuilder are non-synchoronized. iii.StringBuilder is not thread safe, so the performance is less than the string buffer. i and ii. Explanation : StringBuilders are also mutable strings that are stored in heap memory. StringBuilder is not thread-safe. At a time many threads are allowed to access.
i.StringBuffer is mutable strings that are stored in heap memory. ii.The methods of StringBuffer are non-synchoronized. iii.StringBuffer is thread safe, so the performance is less than the StringBuilder. Which of the above statements are correct? i and iii. Explanation : StringBuffer is in java.lang package. StringBuffer is mutable strings that are stored in heap memory. StringBuffer has synchronized methods. StringBuffer is thread safe, so the performance is less than the StringBuilder.
We can generate random numbers in Java. TRUE We can generate random numbers using Random class that presents in java.util package. Random class has the methods to generate random number in int, double, float, long etc. We can give range to random number or we can give the upper bound number.
String a = "Good morning!"; System.out.println(a.charAt(9)); "i"
What is the boolean value of this statement? String string1 = "TEST"; string1.equals(string1.toLowerCase()); false
String a = "Hello"; String b = "World"; a = a + b; a = new String("Hello"); String c = "World"; four
Select the option that is true of Strings in Java String is a class String holds a string of characters String s holds the reference to "Hello World" Strings are objects.
Strings hold only a single character. Ex 'b' would be a String false String holds a string of characters. It could hold -0 or many characters. Also String are indicated with double quotes - " "
for(byte i = 0; i < 5; i++) { System.out.print(i); } 01234
int i = 0; while(i < 5) { if(i == 0) System.out.print(0); i++; System.out.print(i > 2 ? 1 : 2)); } 022111
int i = 0; while(i != 4) } switch(i) { case 0: System.out.print(0); break; case 1: System.out.print(1); default: System.out.print("X"); break; } i++; } 01XXX
Integer i = new Integer(0); if(i==0) System.out.print("="); if(i != 0) if(i > 0) if(i<0) =
char a = 'a'; a += 5; System.out.println(a); f
String x = "bob"; String y = x; String b = new String("bob"); String a = "bob"; if(x==y) "1" if(x==b) "2" if(x==a) "3" 13
What is the size of the int var? 32 bits, 4 bytes
What is the proper format for assigning a value to a variable? int x = 5;
A boolean variable can only hold the values true or false? true
What is the difference between a primitive and a reference variable? A primitive variable stores a value, a reference variable stores the memory address of an object
What is the default type of variable used for decimals? double
int a = 4; System.out.println(a++); 4
What is the value stored in the index[1][2]? 6
for (int count = 1; count < 5; count++) { count = count + count; } // line 4 6
int count = 0; while (count < 2) { System.out.print(“Hi ”); } The loop will run forever
Which of these are valid ways to declare an array? public int[] myArray = new int[3]; public []int myArray = new int[3]; public int myArray[] = new int[3];
String a = new String(); String b = a; a = “Hello”; 2
Integer a = 9; Integer b = new Integer(9); Syso(a == b); false
int a = 10; a = a++ + a + a-- - a-- + ++a; System.out.println(a); The output of this code is 32. The expression on the right-hand side evaluates from left to right, with the following values, which evaluate to 32: a = 10 + 11 + 11 - 10 + 10;
Table 2.12 Precedence of operators Operator Precedence 1 of 3 Postfix Expression++, expression-- Unary ++expression, --expression, +expression, -expression, ! Multiplication * (multiply), / (divide), % (remainder) Addition + (add), - (subtract)
Table 2.12 Precedence of operators Operator Precedence 2 of 3 Relational <, >, <=, >= Equality ==, != Logical AND && Logical OR || Assignment =, +=, -=, *=, /=, %=
Table 2.12 Precedence of operators Operator Precedence 3 of 3 Table 2.12 is limited to the operators that are part of the OCA exam. You can access the complete list at
Created by: wahoo99
Popular Computers sets

 

 



Voices

Use these flashcards to help memorize information. Look at the large card and try to recall what is on the other side. Then click the card to flip it. If you knew the answer, click the green Know box. Otherwise, click the red Don't know box.

When you've placed seven or more cards in the Don't know box, click "retry" to try those cards again.

If you've accidentally put the card in the wrong box, just click on the card to take it out of the box.

You can also use your keyboard to move the cards as follows:

If you are logged in to your account, this website will remember which cards you know and don't know so that they are in the same box the next time you log in.

When you need a break, try one of the other activities listed below the flashcards like Matching, Snowman, or Hungry Bug. Although it may feel like you're playing a game, your brain is still making more connections with the information to help you out.

To see how well you know the information, try the Quiz or Test activity.

Pass complete!
"Know" box contains:
Time elapsed:
Retries:
restart all cards