1000: | ||
500: | ||
100: | ||
50: | ||
20: | ||
10: | ||
5: | ||
10 c: | ||
5 c: | ||
2 c: | ||
1 c: | ||
pointer
Thursday, September 11, 2014
Monday, March 26, 2012
Basic Java Interview Questions & Answers
- 1) Which statement(s) declare an array of string objects?
- String[] s
- String []s
- String[ s]
- String []s
- 2) Which of the following is true about constructor and method ?
- Constructor have its own name,and return type, innvoked using new operator
- Function has its own name, a return type and is invoked using the dot operator
- Constructor has name of class and no return type, and is innvoked using new operator
- 3) Basic I/O is performed by which class?
- Security Manager
- Math
- Run time
- System
- None of these above
- 3 ) An example of polymorphism :
- Inner Class
- Method Over Loading
- Method over ridding
- annonymouse class
- 4) Which is primitive type :
- byte
- String
- Float
- 5) 1.4.56+ "1.2" returns
- String 5.76
- Long 5
- Double 5.76
- String "4.561.2"
- 6) Asssuming that we have not provided any arguments on the command line, the first element of the string array in the main method contains:
- The name of the programe
- null
- empty
- the input for the program
- 7) How do you implement polymorphism in java?
- Method over loading
- Method over overridding through the java inter faces
- Method over overridding through inheritance
- 8) What is the output of the following code
int arrayint[][]=new int[10][20]
int arrayint1[][]={{1,2},{1,4},{6,5}} - 10 & 3
- 20 & 2
- 20 & 3
- 20 & 6
- 9) consider the following code sample
if(a!=null&&a.length()>0){ ...}
what will happen if replace && with &? - Logical error
- Null pointer exception
- There is no output
- None of the above
- 10) there are two classes class A and class B. If class A what to inform B some important information it uses which of the following method(s)
- notify(),notifyall(),wait()
- notify(),notifyall()
- notifyall(),wait()
- None of the above
- 11) when do we get a default constructor
- When the class has no other constructor
- When we define at least one constructor
- When we define a class
- None of the above
- 12) which of the following will output -6?
- System.out.println(Math.floor(-6.7))
- System.out.println(Math.ceil(-6.7))
- System.out.println(Math.Min(-6.7))
- System.out.println(Math.round(-6.7))
- 13) Which of the following are methods of math class
- Absolute()
- log()
- cosine()
- sine()
- None of the above
- 14) when two or more objects are added as listeners of the same event,which listerner will inovked first to handle the event?
- First object that was added as listener
- Last object that was added as listener
- There is no way to determine which listener will be invoked first
- it is impossible to have more than one listener for a given event
- 15) character literals are stored as unicode characters :
- true
- False
please correct me if i am make any mistake :(
Tuesday, February 28, 2012
Thursday, February 23, 2012
Google map pointed to current location
<pre>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset=utf-8>
<meta name="viewport" content="width=620">
<title>HTML5 Demo: geolocation</title>
<link rel="stylesheet" href="css/html5demos.css">
<script src="js/h5utils.js"></script></head>
<body>
<section id="wrapper">
<header>
</header>
<meta name="viewport" content="width=620" />
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<article>
<p>Finding your location: <span id="status">checking...</span></p>
</article>
<script>
function success(position) {
var s = document.querySelector('#status');
if (s.className == 'success') {
// not sure why we're hitting this twice in FF, I think it's to do with a cached result coming back
return;
}
s.innerHTML = "";
s.className = 'success';
var mapcanvas = document.createElement('div');
mapcanvas.id = 'mapcanvas';
mapcanvas.style.height = '400px';
mapcanvas.style.width = '560px';
document.querySelector('article').appendChild(mapcanvas);
var latlng = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);
var myOptions = {
zoom: 15,
center: latlng,
mapTypeControl: false,
navigationControlOptions: {style: google.maps.NavigationControlStyle.SMALL},
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("mapcanvas"), myOptions);
var marker = new google.maps.Marker({
position: latlng,
map: map,
title:"You are here!"
});
}
function error(msg) {
var s = document.querySelector('#status');
s.innerHTML = typeof msg == 'string' ? msg : "failed";
s.className = 'fail';
// console.log(arguments);
}
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(success, error);
} else {
error('not supported');
}
</script>
</section>
<script src="js/prettify.packed.js"></script>
<script>
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script>
try {
var pageTracker = _gat._getTracker("UA-1656750-18");
pageTracker._trackPageview();
} catch(err) {}</script>
</body>
</html>
</pre>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset=utf-8>
<meta name="viewport" content="width=620">
<title>HTML5 Demo: geolocation</title>
<link rel="stylesheet" href="css/html5demos.css">
<script src="js/h5utils.js"></script></head>
<body>
<section id="wrapper">
<header>
</header>
<meta name="viewport" content="width=620" />
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<article>
<p>Finding your location: <span id="status">checking...</span></p>
</article>
<script>
function success(position) {
var s = document.querySelector('#status');
if (s.className == 'success') {
// not sure why we're hitting this twice in FF, I think it's to do with a cached result coming back
return;
}
s.innerHTML = "";
s.className = 'success';
var mapcanvas = document.createElement('div');
mapcanvas.id = 'mapcanvas';
mapcanvas.style.height = '400px';
mapcanvas.style.width = '560px';
document.querySelector('article').appendChild(mapcanvas);
var latlng = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);
var myOptions = {
zoom: 15,
center: latlng,
mapTypeControl: false,
navigationControlOptions: {style: google.maps.NavigationControlStyle.SMALL},
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("mapcanvas"), myOptions);
var marker = new google.maps.Marker({
position: latlng,
map: map,
title:"You are here!"
});
}
function error(msg) {
var s = document.querySelector('#status');
s.innerHTML = typeof msg == 'string' ? msg : "failed";
s.className = 'fail';
// console.log(arguments);
}
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(success, error);
} else {
error('not supported');
}
</script>
</section>
<script src="js/prettify.packed.js"></script>
<script>
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script>
try {
var pageTracker = _gat._getTracker("UA-1656750-18");
pageTracker._trackPageview();
} catch(err) {}</script>
</body>
</html>
</pre>
Wednesday, February 22, 2012
Unzip a file using java
______________________________________________
Here i am giving the code to unzip a zip file
______________________________________________
import java.io.*;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.FileOutputStream;
import java.util.Enumeration;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
public class Unzipfl {
public static void main(String[] args) throws Exception {
String zipname = "wavw.zip"; //File name of zip archieve
File f = new File(zipname.split("\\.")[0]);
f.mkdir();
ZipFile zipFile = new ZipFile(zipname);
Enumeration enumeration = zipFile.entries();
while (enumeration.hasMoreElements()) {
ZipEntry zipEntry = (ZipEntry) enumeration.nextElement();
System.out.println("Unzipping: " + zipEntry.getName());
BufferedInputStream bis = new BufferedInputStream(zipFile.getInputStream(zipEntry));
int size;
byte[] buffer = new byte[2048];
System.out.println("name ="+zipEntry.getName()+"zip file name "+zipname);
BufferedOutputStream bos = new BufferedOutputStream(
new FileOutputStream((zipname.split("\\.")[0])+"\\"+zipEntry.getName()), buffer.length);
while ((size = bis.read(buffer, 0, buffer.length)) != -1) {
bos.write(buffer, 0, size);
}
bos.flush();
bos.close();
bis.close();
}
}
}
Here i am giving the code to unzip a zip file
______________________________________________
import java.io.*;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.FileOutputStream;
import java.util.Enumeration;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
public class Unzipfl {
public static void main(String[] args) throws Exception {
String zipname = "wavw.zip"; //File name of zip archieve
File f = new File(zipname.split("\\.")[0]);
f.mkdir();
ZipFile zipFile = new ZipFile(zipname);
Enumeration enumeration = zipFile.entries();
while (enumeration.hasMoreElements()) {
ZipEntry zipEntry = (ZipEntry) enumeration.nextElement();
System.out.println("Unzipping: " + zipEntry.getName());
BufferedInputStream bis = new BufferedInputStream(zipFile.getInputStream(zipEntry));
int size;
byte[] buffer = new byte[2048];
System.out.println("name ="+zipEntry.getName()+"zip file name "+zipname);
BufferedOutputStream bos = new BufferedOutputStream(
new FileOutputStream((zipname.split("\\.")[0])+"\\"+zipEntry.getName()), buffer.length);
while ((size = bis.read(buffer, 0, buffer.length)) != -1) {
bos.write(buffer, 0, size);
}
bos.flush();
bos.close();
bis.close();
}
}
}
Monday, February 20, 2012
Consume Json from url using jquery
This is my json structure
__________________________________________________________
{
"Data": [
{ "CurrentDistance": 8,
"Id": "78faf314-3a13-4496-b9d0-73f6737de6c5",
"IsOpen": false,
], "ErrorMessage": null, "Success": true
}
__________________________________________________________
Here is the html file to consume json using jquery
____________________________________________________________
____________________________________________________________
__________________________________________________________
{
"Data": [
{ "CurrentDistance": 8,
"Id": "78faf314-3a13-4496-b9d0-73f6737de6c5",
"IsOpen": false,
"Location":
{
"Address": "103 Dominion Road",
"Latitude": -36.871656,
"Longitude": 174.752011
},
"Name": "Champion Bakehouse"
}
], "ErrorMessage": null, "Success": true
}
__________________________________________________________
Here is the html file to consume json using jquery
____________________________________________________________
<!DOCTYPE html>
<html>
<head>
<style>img{ height: 100px; float: left; }</style>
<script src="http://code.jquery.com/jquery-latest.js"></script>
</head>
<body>
<div id="images">
</div>
<script>
function sn()
{
alert('@ sn() ');
$.getJSON("http://mYweBsite/Location.svc/GetNear?callback=?",
{
//parametres for json
format: 'jsonp',
latitude:-36.871641,
longitude:174.752108,
keyword:'Champion',
onlywithspecials:true
},
function(data) {
alert('heloo @ Function '+data);
$.each(data.Data, function(i,Data){
content = '<br/>Current Distance :' + Data.CurrentDistance + '';
content=content+'<br/> ID : '+Data.Id+'<br/>Address :'+Data.Location.Address;
content=content+'<br/>Name :'+Data.Name+'';
$(content).appendTo("#product_list");
});
});
}</script>
<div id="product_list"></div>
<input type="button" value="call fn " onClick="sn();"/>
</body>
</html>
____________________________________________________________
Subscribe to:
Posts (Atom)