IndiaBIX.com
Arithmetic Aptitude Data Interpretation
Logical Reasoning Verbal Reasoning Non Verbal Reasoning
General Knowledge
Sudoku Number puzzles Missing letters puzzles Logical puzzles Playing cards puzzles Clock puzzles
C Programming C++ Programming C# Programming Java Programming
Microbiology Biochemistry Biotechnology Biochemical Engineering
Chemical Engineering Networking Database Questions Computer Science Basic Electronics Digital Electronics Electronic Devices Circuit Simulation Electrical Enigneering Engineering Mechanics Technical Drawing
Placement Papers Group Disucssion HR Interview Technical Interview Body Language
Aptitude Test Verbal Ability Test Verbal Reasoning Test Logical Reasoning Test C Programming Test Java Programming Test Data Interpretation Test General Knowledge Test
Data Structures Operating Systems Networking DATABASE Database Basics SQL Server Basics SQL Server Advanced SQL Server 2008 JAVA Core Java Java Basics Advanced Java UNIX Unix File Management Unix Memory Management Unix Process Managemnt C Interview Questions The C Language Basics .NET Interview Questions .NET Framework ADO.NET ASP.NET Software Testing

Java Programming - Language Fundamentals - Discussion

@ : Home > Java Programming > Language Fundamentals > General Questions - Discussion

Read more:

"Everything should be made as simple as possible, but not simpler."
- Albert Einstein
1. 

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

  1. int -> 0
  2. String -> "null"
  3. Dog -> null
  4. char -> '\u0000'
  5. float -> 0.0f
  6. boolean -> true

[A]. 1, 2, 3, 4[B]. 1, 3, 4, 5
[C]. 2, 4, 5, 6[D]. 3, 4, 5, 6

Answer: Option B

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.


Boopalan V said: (Tue, Jul 20, 2010 10:05:20 AM)    
 
Is there any primitive data type named Dog?

Sijo.S said: (Thu, Sep 30, 2010 11:42:16 PM)    
 
What is the use of data type 'Dog'. I didnt heard about that!

Sundar said: (Fri, Oct 1, 2010 02:47:03 AM)    
 
Hi All,

Dog - There is no primitive datatype like 'Dog'. It is a User Defined type (a class created by User). By default it will hold null value.

For example:

public class Dog
{
//...
}

Dog myDog;

Here myDog will contain 'null' value by default.

Hope you understand. Have a nice day!

Garima S said: (Wed, Oct 13, 2010 09:19:01 AM)    
 
Not able to undestand the given question.

Can anyone please explain it to me?

Hemangini Kulkarni said: (Fri, Nov 12, 2010 04:50:40 AM)    
 
Dear Sir,

1) Default value for array element of type char is nothing , not even null
2) Default value for array element of type float is 0.0 not 0.0f

class hello
{
public static void main(String str[])
{
int i[] = new int[5];
float f[] = new float[5];
double d[] = new double[5];
String s[] = new String[5];
char c[] = new char[5];
boolean b[] = new boolean[5];

System.out.println("Hello World");
System.out.println("Integer "+i[0]);
System.out.println("Float "+ f[0]);
System.out.println("Double " + d[0]);
System.out.println("String " + s[0]);
System.out.println("Character " + c[0]);
System.out.println("Boolean " + b[0]);
}
}

Piyush Gadekar said: (Mon, Jan 31, 2011 12:49:21 AM)    
 
What your are tryng to admit from this program?

Shaswati said: (Fri, Feb 25, 2011 09:09:06 AM)    
 
How option 4 is correct? I could not understand. Please explain about the default data type of char.

Sundar said: (Thu, Mar 17, 2011 01:01:30 AM)    
 
@Shaswati

It is nothing but a class created by a user.

Ex: Dog, Student, Car etc.

The question is 'what will be default value?'.


Student objStud1;

Here objStud1 will contain 'null' value by default.

Prathyusha said: (Sun, Mar 20, 2011 11:35:59 AM)    
 
HI,
No where the "Dog" datatype is mentioned.
If Dog is integer , the default might be -0
If Dog is float , the default might be -0.0f
If Dog is object ,the default might be -null
.... No where it is mentioned whether Dog is wat datatype.
HELP ME IN THIS REGARD.....

Suganthan.M said: (Tue, Mar 22, 2011 08:07:54 AM)    
 
Dog - There is no primitive datatype like 'Dog'. It is a User Defined type. By default it will hold null value.

Suresh said: (Fri, Jul 1, 2011 12:58:41 PM)    
 
Nice answers

Kathirozhi said: (Sat, Sep 17, 2011 01:16:20 PM)    
 
Plese correctly tell the char default value is nothing or not null or the answer in the question please help to understand.

Rehana said: (Sun, Oct 2, 2011 12:20:42 PM)    
 
What is that \u declared in char?

Sivachandran said: (Thu, Jan 12, 2012 04:18:54 PM)    
 
@Kathirozhi not null and nothing nice answers.

Amarjeetkaur said: (Fri, Jan 13, 2012 07:51:40 AM)    
 
Please tell me anyone, what is the history of java ? In briefly words.

Gaurav said: (Wed, Feb 1, 2012 11:16:14 AM)    
 
The most important feature of Java language is that it is Architecture Neutral. Earlier softwares were build for specific operating systems, Like softwares build for Windows They run only in windows not in other os like linux, unix, max etc. To resolve this A new language was introduced by Sunmicrosystems Known as Java and so many features were introduced in this language which makes it a powerful language.

Deepi said: (Wed, Feb 8, 2012 08:51:29 PM)    
 
Char default value is a space only know then how?

Basha said: (Mon, Feb 13, 2012 11:03:13 AM)    
 
Hi All,

default values are given as follows:
Int------>0
String---> null
Dog (Object)------->null
Char -------------->"\u0000". it is hexa decimal representation of asii code of the chars. I think "\u0000" represents "space".
boolean------------> false.

Done.

Ranjith said: (Mon, Feb 20, 2012 02:51:03 PM)    
 
Hi , in the given programe the dog is a object ,
which may any data type
the below programe illistreates

class Dv
{
int x;
}

class DefaultValues
{
public static void main(String str[])
{
Dv dog=new Dv();

int a[] = new int[5];
float b[] = new float[5];
double c[] = new double[5];
String d[] = new String[5];
char e[] = new char[5];
boolean f[] = new boolean[5];
System.out.println("Hi ,The Default Values: ");
System.out.println("For Object :"+dog.x);// here dog is object
System.out.println("Integer "+a[0]);
System.out.println("Float "+ b[0]);
System.out.println("Double " + c[0]);
System.out.println("String " + d[0]);
System.out.println("Character " + e[0]);
System.out.println("Boolean " + f[0]);
}
}

Write your comments here:
Name *:     Email:


© 2008-2012 by IndiaBIX™ Technologies. All Rights Reserved | Copyright | Terms of Use & Privacy Policy

Contact us: info@indiabix.com     Follow us on twitter!