Language Fundamentals Questions and Answers updated daily – Java



10 Language Fundamentals Questions and answers section with explanation for various online exam preparation, various interviews, Java Language Fundamentals online test. Language Fundamentals Questions with detailed description, explanation will help you to master the topic.

Language Fundamentals Questions

1.
Which three are valid declarations of a float?

float f1 = -343;
float f2 = 3.14;
float f3 = 0x12345;
float f4 = 42e7;
float f5 = 2001.0D;
float f6 = 2.81F;



SHOW ANSWER
Correct Ans:1,3,6
Explanation:
(1) and (3) are integer literals (32 bits), and integers can be legally assigned to floats (also 32 bits). (6) is correct because (F) is appended to the literal, declaring it as a float rather than a double (the default for floating point literals).

(2), (4),and (5) are all doubles.


2.
What is the numerical range of a char?



SHOW ANSWER
Correct Ans:0 to 65535
Explanation:
A char is really a 16-bit integer behind the scenes, so it supports 216 (from 0 to 65535) values.


3.
Which three are valid declarations of a char?

char c1 = 064770;
char c2 = 'face';
char c3 = 0xbeef;
char c4 = u0022;
char c5 = 'iface';
char c6 = 'uface';



SHOW ANSWER
Correct Ans:1,3,6
Explanation:
(1), (3), and (6) are correct. char c1 = 064770; is an octal representation of the integer value 27128, which is legal because it fits into an unsigned 16-bit integer. char c3 = 0xbeef; is a hexadecimal representation of the integer value 48879, which fits into an unsigned 16-bit integer. char c6 = 'uface'; is a Unicode representation of a character.

char c2 = 'face'; is wrong because you can't put more than one character in a char literal. The only other acceptable char literal that can go between single quotes is a Unicode value, and Unicode literals must always start with a 'u'.

char c4 = u0022; is wrong because the single quotes are missing.

char c5 = 'iface'; is wrong because it appears to be a Unicode representation (notice the backslash), but starts with 'i' rather than 'u'.


4.
public interface Foo 
    int k = 4; /* Line 3 */
}
Which three piece of codes are equivalent to line 3?
final int k = 4;
public int k = 4;
static int k = 4;
abstract int k = 4;
volatile int k = 4;
protected int k = 4;



SHOW ANSWER
Correct Ans:1,2,3
Explanation:
(1), (2) and (3) are correct. Interfaces can have constants, which are always implicitly public, static, and final. Interface constant declarations of public, static, and final are optional in any combination.


5.
Which three are legal array declarations?

int [] myScores [];
char [] myChars;
int [6] myScores;
Dog myDogs [];
Dog myDogs [7];



SHOW ANSWER
Correct Ans:1,2,4
Explanation:
(1), (2), and (4) are legal array declarations. With an array declaration, you can place the brackets to the right or left of the identifier. Option A looks strange, but it's perfectly legal to split the brackets in a multidimensional array, and place them on both sides of the identifier. Although coding this way would only annoy your fellow programmers, for the exam, you need to know it's legal.

(3) and (5) are wrong because you can't declare an array with a size. The size is only needed when the array is actually instantiated (and the JVM needs to know how much space to allocate for the array, based on the type of array and the size).


6. Which is a valid keyword in java?



SHOW ANSWER
Correct Ans:interface
Explanation:
interface is a valid keyword.

Option B is wrong because although "String" is a class type in Java, "string" is not a keyword.

Option C is wrong because "Float" is a class type. The keyword for the Java primitive is float.

Option D is wrong because "unsigned" is a keyword in C/C++ but not in Java.


7. Which is a reserved word in the Java programming language?



SHOW ANSWER
Correct Ans:native
Explanation:
The word "native" is a valid keyword, used to modify a method declaration.

Option A, D and E are not keywords. Option C is wrong because the keyword for subclassing in Java is extends, not 'subclasses'.


8. Which will legally declare, construct, and initialize an array?



SHOW ANSWER
Correct Ans:int [] myList = {"4", "3", "7"};
Explanation:
The only legal array declaration and assignment statement is Option D

Option A is wrong because it initializes an int array with String literals.

Option B is wrong because it use something other than curly braces for the initialization.

Option C is wrong because it provides initial values for only one dimension, although the declared array is a two-dimensional array.


9. Which one of these lists contains only Java programming language keywords?



SHOW ANSWER
Correct Ans:goto, instanceof, native, finally, default, throws
Explanation:
All the words in option B are among the 49 Java keywords. Although goto reserved as a keyword in Java, goto is not used and has no function.

Option A is wrong because the keyword for the primitive int starts with a lowercase i.

Option C is wrong because "virtual" is a keyword in C++, but not Java.

Option D is wrong because "constant" is not a keyword. Constants in Java are marked static and final.

Option E is wrong because "include" is a keyword in C, but not in Java.


10.
Which four options describe the correct default values for array elements of the types indicated?

int -> 0
String -> "null"
Dog -> null
char -> 'u0000'
float -> 0.0f
boolean -> true



SHOW ANSWER
Correct Ans:1,3,4,5
Explanation:
(1), (3), (4), (5) are the correct statements.

(2) is wrong because the default value for a String (and any other object reference) is null, with no quotes.

(6) is wrong because the default value for boolean elements is false.


Are you seeking for good platform for practicing Language Fundamentals questions in online. This is the right place. The time you spent in Fresherslive will be the most beneficial one for you.

Online Test on Language Fundamentals @ Fresherslive

This page provides important questions on Language Fundamentals along with correct answers and clear explanation, which will be very useful for various Interviews, Competitive examinations and Entrance tests. Here, Most of the Language Fundamentals questions are framed with Latest concepts, so that you may get updated through these Language Fundamentals Online tests. Language Fundamentals Online Test questions are granted from basic level to complex level.

Why To Practice Language Fundamentals Test questions Online @ Fresherslive?

Language Fundamentals questions are delivered with accurate answer. For solving each and every question, very lucid explanations are provided with diagrams wherever necessary.

Practice in advance of similar questions on Language Fundamentals may improve your performance in the real Exams and Interview.

Time Management for answering the Language Fundamentals questions quickly is foremost important for success in Competitive Exams and Placement Interviews.

Through Fresherslive Language Fundamentals questions and answers, you can acquire all the essential idea to solve any difficult questions on Language Fundamentals in short time and also in short cut method.

Winners are those who can use the simplest method for solving a question. So that they have enough time for solving all the questions in examination, correctly without any tense. Fresherslive provides most simplest methods to answer any tough questions. Practise through Fresherslive test series to ensure success in all competitive exams, entrance exams and placement tests.

Why Fresherslive For Language Fundamentals Online Test Preparation?

Most of the job seekers finding it hard to clear Language Fundamentals test or get stuck on any particular question, our Language Fundamentals test sections will help you to success in Exams as well as Interviews. To acquire clear understanding of Language Fundamentals, exercise these advanced Language Fundamentals questions with answers.

You're Welcome to use the Fresherslive Online Test at any time you want. Start your beginning, of anything you want by using our sample Language Fundamentals Online Test and create yourself a successful one. Fresherslive provides you a new opportunity to improve yourself. Take it and make use of it to the fullest. GOODLUCK for Your Bright Future.


FreshersLive - No.1 Job site in India. Here you can find latest 2017 government as well as private job recruitment notifications for different posts vacancies in India. Get top company jobs for both fresher and experienced. Job Seekers can get useful interview tips, resume services & interview Question and answer. Practice online test free which is helpful for interview preparation. Register with us to get latest employment news/rojgar samachar notifications. Also get latest free govt and other sarkari naukri job alerts daily through E-mail.